Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

at_least(:once) doesn't work as documented #40

Closed
hisenb3rg opened this issue Feb 19, 2011 · 3 comments
Closed

at_least(:once) doesn't work as documented #40

hisenb3rg opened this issue Feb 19, 2011 · 3 comments

Comments

@hisenb3rg
Copy link

Example:
@obj = Object.new
@obj.should_receive(:to_s).at_least(:once) {"testing"}
@obj.to_s.should == "testing"

Upper test fails. It works if I modify the expectation line like that, but doesn't read right:
@obj.should_receive(:to_s).at_least(:once).times {"testing"}

@myronmarston
Copy link
Member

Allow users to specify return values by passing a block to #at_least, #at_most and #exactly.

  • @mock.should_receive(:to_s).at_least(:once) { "return val" }
  • @mock.should_receive(:to_s).at_most(:once) { "return val" }
  • @mock.should_receive(:to_s).exactly(:once) { "return val" }

Each of the above now work but previously returned nothing since the block was discarded.

Closed by 0f09860.

@myronmarston
Copy link
Member

Thanks for reporting this bug! It's fixed in master now.

@hisenb3rg
Copy link
Author

Glad I did, thanks for fast response!

myronmarston added a commit to myronmarston/rspec-mocks that referenced this issue Oct 21, 2012
… #at_most and #exactly.

- @mock.should_receive(:to_s).at_least(:once) { "return val" }
- @mock.should_receive(:to_s).at_most(:once) { "return val" }
- @mock.should_receive(:to_s).exactly(:once) { "return val" }

Each of the above now work but previously returned nothing since the block was discarded.

Closes rspec#40.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants