If your code raises an error whose message attempts to reference a property of a test double, RSpec will throw an exception complaining that the lifecycle
bundle && rspec example_spec.rb will reproduce the issue.
A normal RSpec error message saying an exception was raised in that particular test, including the exception's message. Other tests render properly.
FF
Failures:
1) MyError has a message including the object's body
Failure/Error: raise MyError.new(object)
MyError:
I ran into a problem
# ./example_spec.rb:19:in `block (2 levels) in <top (required)>'
2) MyError still shows other failure messages
Failure/Error: expect(1).to be(2)
expected #<Fixnum:5> => 2
got #<Fixnum:3> => 1
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./example_spec.rb:24:in `block (2 levels) in <top (required)>'
Finished in 0.00796 seconds (files took 0.07125 seconds to load)
2 examples, 2 failures
Failed examples:
rspec ./example_spec.rb:14 # MyError has a message including the object's body
rspec ./example_spec.rb:22 # MyError still shows other failure messages
RSpec throws an internal error when rendering the message and does not render further test failures.
FF
/path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/space.rb:51:in `raise_lifecycle_message': The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported. (RSpec::Mocks::OutsideOfExampleError)
from /path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/space.rb:11:in `proxy_for'
from /path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/test_double.rb:111:in `__mock_proxy'
from /path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/test_double.rb:74:in `method_missing'
from /path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/proxy.rb:195:in `message_received'
from /path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/method_double.rb:77:in `proxy_method_invoked'
from /path/to/rspec-mocks-3.5.0.beta2/lib/rspec/mocks/method_double.rb:64:in `block (2 levels) in define_proxy_method'
from /path/to/rspec-repro/example_spec.rb:9:in `message'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:174:in `exception_lines'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:149:in `block in failure_lines'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:146:in `tap'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:146:in `failure_lines'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:32:in `colorized_message_lines'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:231:in `formatted_message_and_backtrace'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:84:in `fully_formatted_lines'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/exception_presenter.rb:76:in `fully_formatted'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/notifications.rb:200:in `fully_formatted'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/notifications.rb:114:in `block in fully_formatted_failed_examples'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/notifications.rb:113:in `each'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/notifications.rb:113:in `each_with_index'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/notifications.rb:113:in `fully_formatted_failed_examples'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/formatters/base_text_formatter.rb:33:in `dump_failures'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:189:in `block in notify'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:188:in `each'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:188:in `notify'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:160:in `block in finish'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:175:in `close_after'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:156:in `finish'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/reporter.rb:79:in `report'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/runner.rb:117:in `run_specs'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/runner.rb:93:in `run'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/runner.rb:78:in `run'
from /path/to/rspec-core-3.5.0.beta2/lib/rspec/core/runner.rb:45:in `invoke'
from /path/to/rspec-core-3.5.0.beta2/exe/rspec:4:in `<top (required)>'