Permalink
Browse files

Test expectation block added to a stub

Current behavior: When setting expectations on a stub variable that
include a block, the block is not executed when the expectations are
being evaluated.

Expected behavior: I would want the block to be evaluated just like it
is evaluated when not setting the expectation on a stub existing
before.
  • Loading branch information...
1 parent e2c2e27 commit ca81ef166591ed959aef6b9fd0d2fcf3b50cf8f2 @mkilling committed Nov 11, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 test/shared_test.rb
View
@@ -73,4 +73,19 @@ def test_verification_that_non_expected_stub_didnt_occur
assert_not_requested(@stub_http)
end
end
+
+ def test_that_block_is_executed_when_setting_expectations_on_the_stub
+ called = false
+ stub = stub_request(:get, "http://www.example.com/")
+ http_request(:get, "http://www.example.com/")
+ assert_requested(stub, :times => 1) { called = true }
+ assert called, "block was not executed"
+ end
+
+ def test_that_block_is_executed_when_setting_expectations
+ called = false
+ http_request(:get, "http://www.example.com/")
+ assert_requested(:get, "http://www.example.com/", :times => 1) { called = true }
+ assert called, "block was not executed"
+ end
end

0 comments on commit ca81ef1

Please sign in to comment.