[rspec-devel] [ rspec-Feature Requests-8484 ] should_receive with blocks and cardinality

noreply at rubyforge.org noreply at rubyforge.org
Wed Feb 7 14:28:04 EST 2007


Feature Requests item #8484, was opened at 2007-02-07 13:28
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=8484&group_id=797

Category: mock module
Group: None
Status: Open
Priority: 3
Submitted By: Micah Martin (slagyr)
Assigned to: Nobody (None)
Summary: should_receive with blocks and cardinality

Initial Comment:
the mock.should_receive method should accept cardinatliy along with blocks.

  specify "mock should receive call twice with block" do
    my_mock = mock("my mock")
    
    calls = 0
    my_mock.should_receive(:foo).twice { calls = calls + 1 }
    
    my_mock.foo
    my_mock.foo
    
    calls.should_eql 2
  end
  
  specify "mock should receive exactly 10 times with param" do
    my_mock = mock("my mock")
    
    sum = 0
    my_mock.should_receive(:foo).exactly(10).times { |i| sum = sum + i }
    
    10.times { |i| my_mock.foo(i) }
    
    sum.should_eql 45 
  end

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=8484&group_id=797


More information about the rspec-devel mailing list