From dd7067fffa4a612bb110049178788399b6fcf1ab Mon Sep 17 00:00:00 2001 From: uk-ar Date: Mon, 15 Dec 2014 06:45:47 +0900 Subject: [PATCH] Fix execution_result to fit rspec3 --- lib/guard/rspec_formatter.rb | 6 +++++- spec/lib/guard/rspec_formatter_spec.rb | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/guard/rspec_formatter.rb b/lib/guard/rspec_formatter.rb index d1932227..995e9c56 100644 --- a/lib/guard/rspec_formatter.rb +++ b/lib/guard/rspec_formatter.rb @@ -92,7 +92,11 @@ def _write(&block) def _failed_paths failed = examples.select do |e| - e.execution_result[:status].to_s == "failed" + if self.class.rspec_3? + e.execution_result.status.to_s == "failed" + else + e.execution_result[:status].to_s == "failed" + end end klass = self.class diff --git a/spec/lib/guard/rspec_formatter_spec.rb b/spec/lib/guard/rspec_formatter_spec.rb index bacc927f..06ae48b9 100644 --- a/spec/lib/guard/rspec_formatter_spec.rb +++ b/spec/lib/guard/rspec_formatter_spec.rb @@ -54,6 +54,10 @@ ) end + before do + allow(formatter.class).to receive(:rspec_3?).and_return(false) + end + def expected_output(spec_filename) /^3 examples, 1 failures in 123\.0 seconds\n#{spec_filename}\n$/ end @@ -81,6 +85,13 @@ def expected_output(spec_filename) allow(formatter.class).to receive(:rspec_3?).and_return(true) end + let(:failed_example) do + double( + execution_result: double(status: "failed"), + metadata: { location: spec_filename } + ) + end + it "writes summary line and failed location" do allow(formatter).to receive(:examples) { [failed_example] } formatter.dump_summary(notification)