spec/scss_lint/cli_spec.rb in scss-lint-0.29.0 vs spec/scss_lint/cli_spec.rb in scss-lint-0.30.0
- old
+ new
@@ -91,20 +91,63 @@
context 'when the exclude linters flag is set' do
let(:flags) { %w[-x FakeTestLinter1] }
it 'includes all linters except the excluded one' do
safe_parse
- subject.config.enabled_linters.should == [SCSSLint::Linter::FakeTestLinter2]
+ subject.config.enabled_linters.should == \
+ [SCSSLint::Linter::FakeTestLinter2]
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
+ expect { subject.instance_eval %{ URI } }.to_not raise_error
+ end
+ end
+
+ context 'when neither format nor out flag is set' do
+ let(:flags) { %w[] }
+
+ it 'sets the default reporter to output to stdout' do
+ safe_parse
+ subject.options[:reporters].should \
+ include([SCSSLint::Reporter::DefaultReporter, :stdout])
+ end
+ end
+
+ context 'when the out flag is set' do
+ context 'and the path is valid' do
+ let(:flags) { %w[--out foo.txt] }
+
+ it 'sets the default :output to the given path' do
+ safe_parse
+ subject.options[:reporters].should \
+ include([SCSSLint::Reporter::DefaultReporter, 'foo.txt'])
+ end
+ end
+ end
+
context 'when the format flag is set' do
context 'and the format is valid' do
let(:flags) { %w[--format XML] }
it 'sets the :reporter option to the correct reporter' do
safe_parse
- subject.options[:reporter].should == SCSSLint::Reporter::XMLReporter
+ subject.options[:reporters].should \
+ include([SCSSLint::Reporter::XMLReporter, :stdout])
+ end
+ end
+
+ context 'and an out path is specified' do
+ let(:flags) { %w[--format XML --out foo.txt] }
+
+ it 'sets the specified reporter :output to the given path' do
+ safe_parse
+ subject.options[:reporters].should \
+ include([SCSSLint::Reporter::XMLReporter, 'foo.txt'])
end
end
context 'and the format is invalid' do
let(:flags) { %w[--format InvalidFormat] }