Skip to content

Commit

Permalink
Add --require switch to CLI with tests
Browse files Browse the repository at this point in the history
Change-Id: I3673b203232bd4914ada415a3abf0710a12e052d
Reviewed-on: http://gerrit.causes.com/44291
Tested-by: jenkins <[email protected]>
Reviewed-by: Shane da Silva <[email protected]>
  • Loading branch information
Adam Eberlin authored and sds committed Nov 7, 2014
1 parent 835672f commit 6f566c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Command Line Flag | Description
`-e`/`--exclude` | Exclude one or more files from being linted
`-f`/`--format` | Output format (see [Formatters](#formatters))
`-o`/`--out` | Write output to a file instead of STDOUT
`-r`/`--require` | Require file/library (mind `$LOAD_PATH`, uses `Kernel.require`)
`-i`/`--include-linter` | Specify which linters you specifically want to run
`-x`/`--exclude-linter` | Specify which linters you _don't_ want to run
`-h`/`--help` | Show command line flag documentation
Expand Down
4 changes: 4 additions & 0 deletions lib/scss_lint/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def options_parser # rubocop:disable MethodLength
define_output_path(path)
end

opts.on('-r', '--require path', 'Require Ruby file', String) do |path|
require path
end

opts.on_tail('--show-formatters', 'Shows available formatters') do
print_formatters
end
Expand Down
9 changes: 9 additions & 0 deletions spec/scss_lint/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ def safe_parse
end
end

context 'when the require flag is set' do
let(:flags) { %w[--require uri] }

it 'requires the specified file and constants are accessible' do
safe_parse
proc { subject.instance_eval %{ URI } }.should_not raise_error
end
end

context 'when neither format nor out flag is set' do
let(:flags) { %w[] }

Expand Down

0 comments on commit 6f566c3

Please sign in to comment.