spec/cli_spec.rb in preek-1.5.1 vs spec/cli_spec.rb in preek-1.6.0
- old
+ new
@@ -7,10 +7,11 @@
def test_file(file_name)
File.expand_path(File.join(File.dirname(__FILE__),'test_files/',"#{file_name}.rb"))
end
+
describe 'Commands' do
context 'errors' do
When(:output) { capture(:stderr) { Preek::CLI.start args } }
@@ -163,9 +164,19 @@
context "when given one file without smells and another with smells" do
Given(:args){ [test_file('non_smelly'), test_file('too_many_statements')] }
Then{expect(output).to include(args[1], args[0])}
end
end
+
+ # Also tests proper output fully
+ context "with --compact option" do
+ Given(:args){ [test_file('too_many_statements')] }
+ Given(:dir){File.dirname(__FILE__)}
+ Given(:expected_output){"\n-\n\nfile: #{dir}/test_files/too_many_statements.rb\nclass: TooManyStatments\nsmells: \n#loong_method has approx 7 statements (TooManyStatements) at lines 4\n\n-\n\ntotal: 1\n\n-\n\n"}
+ When(:output) { capture(:stdout) { Preek::CLI.start ['-c'].concat(args) } }
+ Then{expect(output).to eq expected_output}
+ end
+
end
describe 'Git' do
Given(:cli) { Preek::CLI.new }
Given{cli.stub(:git_status).and_return(git_output)}
\ No newline at end of file