Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added spec to show you can yield() with no value yielded, for a stub …

…method
  • Loading branch information...
commit 131ee2da8b25f44584dac6949ab0b5cdcc9fb062 1 parent 9c49561
@derickbailey authored
Showing with 21 additions and 3 deletions.
  1. +21 −3 spec/stub_method_with_block_spec.rb
View
24 spec/stub_method_with_block_spec.rb
@@ -143,9 +143,7 @@ def do_something
describe NotAMock::Stubber, "when stubbing a method that yields nil" do
before :each do
@bt = BlockTest.new
-
- p = proc { yield false if block_given?}
- @output = @bt.stub_method(:method_that_yields_a_value, &p).yields(nil)
+ @output = @bt.stub_method(:method_that_yields_a_value).yields(nil)
@yielded_value = "not nil"
@bt.method_that_yields_a_value(){ |v|
@@ -161,3 +159,23 @@ def do_something
@yielded_value.should be_nil
end
end
+
+describe NotAMock::Stubber, "when stubbing a method and yielding with no values" do
+ before :each do
+ @bt = BlockTest.new
+ @output = @bt.stub_method(:method_that_yields_a_value).yields
+
+ @yielded = false
+ @bt.method_that_yields_a_value(){
+ @yielded = true
+ }
+ end
+
+ after :each do
+ NotAMock::Stubber.instance.reset
+ end
+
+ it "should yield" do
+ @yielded.should be_true
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.