Created
June 6, 2012 18:38
-
-
Save smazhara/2883805 to your computer and use it in GitHub Desktop.
rspec's should_receive with implicit subject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
» rspec string_spec.rb | |
F | |
Failures: | |
1) String | |
Failure/Error: it { should_receive(:size) } | |
(#<RSpec::Core::ExampleGroup::Nested_1:0x000000013e67b8>).size(any args) | |
expected: 1 time | |
received: 0 times | |
# ./string_spec.rb:4:in `block (2 levels) in <top (required)>' | |
Finished in 0.00091 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./string_spec.rb:4 # String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe String do | |
subject { "asdf" } | |
after { subject.size } | |
it { should_receive(:size) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example showing unexpected spec failure as should_receive is not respecting implicit subject. This passes with explicit subject: subject.should_receive(:size)