Skip to content

Commit

Permalink
Make spec resilient to changes to this spec file.
Browse files Browse the repository at this point in the history
Hard coding the line number was very brittle.
  • Loading branch information
myronmarston committed Aug 20, 2016
1 parent b54e2a1 commit 3512b23
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spec/rspec/core/formatters/exception_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ module RSpec::Core
instance_double(Exception, :cause => first_exception, :message => "Second\nexception", :backtrace => ["#{__FILE__}:#{__LINE__}"])
end

caused_by_line_num = __LINE__ + 2
let(:first_exception) do
instance_double(Exception, :cause => nil, :message => "Real\nculprit", :backtrace => ["#{__FILE__}:#{__LINE__}"])
end
Expand All @@ -155,7 +156,7 @@ module RSpec::Core
| # --- Caused by: ---
| # Real
| # culprit
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:140
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{caused_by_line_num}
EOS
end

Expand Down

0 comments on commit 3512b23

Please sign in to comment.