Skip to content
Browse files

should pass block to expectation block

  • Loading branch information...
1 parent b61073f commit 7e5530046e33b2653cdbc4bf08907a8638f8605c @nbraem nbraem committed with dchelimsky
Showing with 12 additions and 3 deletions.
  1. +3 −3 lib/rspec/mocks/message_expectation.rb
  2. +9 −0 spec/rspec/mocks/mock_spec.rb
View
6 lib/rspec/mocks/message_expectation.rb
@@ -115,7 +115,7 @@ def invoke(*args, &block)
Kernel::throw @symbol_to_throw unless @symbol_to_throw.nil?
default_return_val = if !@method_block.nil?
- invoke_method_block(*args)
+ invoke_method_block(*args, &block)
elsif !@args_to_yield.empty? || @eval_context
invoke_with_yield(&block)
else
@@ -141,9 +141,9 @@ def called_max_times?
protected
- def invoke_method_block(*args)
+ def invoke_method_block(*args, &block)
begin
- @method_block.call(*args)
+ @method_block.call(*args, &block)
rescue => detail
@error_generator.raise_block_failed_error(@sym, detail.message)
end
View
9 spec/rspec/mocks/mock_spec.rb
@@ -144,6 +144,15 @@ module Mocks
}.to raise_error(RSpec::Mocks::MockExpectationError, /Double \"test double\" received :something but passed block failed with: expected false to be true/)
end
+ it "passes block to expectation block" do
+ a = nil
+ @mock.should_receive(:something) { |&block| a = block }
+ b = lambda { }
+ @mock.something(&b)
+ a.should == b
+ @moc.rspec_verify
+ end
+
it "fails right away when method defined as never is received" do
@mock.should_receive(:not_expected).never
expect { @mock.not_expected }.to raise_error(

0 comments on commit 7e55300

Please sign in to comment.
Something went wrong with that request. Please try again.