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

Closed
jurglic opened this Issue Feb 19, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@jurglic

jurglic commented Feb 19, 2011

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

This comment has been minimized.

Show comment Hide comment
@myronmarston

myronmarston Feb 20, 2011

Owner

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.

Owner

myronmarston commented Feb 20, 2011

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

This comment has been minimized.

Show comment Hide comment
@myronmarston

myronmarston Feb 20, 2011

Owner

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

Owner

myronmarston commented Feb 20, 2011

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

@jurglic

This comment has been minimized.

Show comment Hide comment
@jurglic

jurglic Feb 20, 2011

Glad I did, thanks for fast response!

jurglic commented Feb 20, 2011

Glad I did, thanks for fast response!

myronmarston added a commit to myronmarston/rspec-mocks that referenced this issue Oct 21, 2012

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.

Closes #40.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment