spec/plugins/pre_commit/message/formatter_spec.rb in java-checkstyle-1.0.3 vs spec/plugins/pre_commit/message/formatter_spec.rb in java-checkstyle-1.0.4

- old
+ new

@@ -25,11 +25,10 @@ "column"=>"40", "severity"=>"error", "message"=>"some error message", "source"=>"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck" }]) - } context "When has empty input" do it {expect{ formatter.format(nil) }.to raise_error(ArgumentError)} end @@ -40,20 +39,24 @@ end context "When has one file" do let(:errors) { Domain::Checkstyle.new( [ file_error ] ) } - it{ expect(formatter.format(errors)).to include "File errors: /some/path/file_name.java"} - it{ expect(formatter.format(errors)).to include " line: 1: error: some error message"} + before { @formatted_output = formatter.format(errors)} + + it{ expect( @formatted_output ).to include "File errors: /some/path/file_name.java"} + it{ expect( @formatted_output ).to include " line: 1: error: some error message"} end context "When has more than one file" do let(:errors) do Domain::Checkstyle.new( [ file_error, file_error_2 ] ) end - it{ expect(formatter.format(errors)).to include "File errors: /some/path/file_name.java"} - it{ expect(formatter.format(errors)).to include " line: 1: error: some error message"} - it{ expect(formatter.format(errors)).to include "File errors: /some/path/file_name2.java"} - it{ expect(formatter.format(errors)).to include " line: 11:40 error: some error message"} + before { @formatted_output = formatter.format(errors) } + + it{ expect( @formatted_output ).to include "File errors: /some/path/file_name.java"} + it{ expect( @formatted_output ).to include " line: 1: error: some error message"} + it{ expect( @formatted_output ).to include "File errors: /some/path/file_name2.java"} + it{ expect( @formatted_output ).to include " line: 11:40 error: some error message"} end end