Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit a02018d

Browse files
committed
Add spec documenting the fact that null-ness doesn't persist between examples.
1 parent 372346a commit a02018d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Breaking Changes for 3.0.0:
1111
leaving `double(name, methods)` for creating test doubles. (Sam Phippen)
1212
* Remove `any_number_of_times` since `should_receive(:msg).any_number_of_times`
1313
is really a stub in a mock's clothing. (Sam Phippen)
14+
* Remove support for re-using the same null-object test double in multiple
15+
examples. Test doubles are designed to only live for one example.
16+
(Myron Marston)
1417

1518
### 2.14.0 / 2013-07-06
1619
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0.rc1...v2.14.0)

spec/rspec/mocks/null_object_mock_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ module Mocks
8888
# returns an int value from #to_int.
8989
expect(("%i" % @double)).to eq("0")
9090
end
91+
92+
it "does not allow null-ness to persist between examples" do
93+
RSpec::Mocks.teardown
94+
95+
expect(@double).not_to be_null_object
96+
expect { @double.some.long.message.chain }.to raise_error(RSpec::Mocks::MockExpectationError)
97+
98+
@double.as_null_object
99+
expect(@double).to be_null_object
100+
expect { @double.some.long.message.chain }.not_to raise_error
101+
end
91102
end
92103

93104
describe "#as_null_object" do

0 commit comments

Comments
 (0)