Skip to content

Commit

Permalink
Merge branch 'master', remote branch 'libc/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Takita committed Oct 31, 2010
2 parents f08f279 + 906f86e commit 107fd09
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/rr/method_dispatches/method_missing_dispatch.rb
Expand Up @@ -16,7 +16,6 @@ def call
if Injections::DoubleInjection.exists?(subject_class, method_name)
@double = find_double_to_attempt
if double
call_yields
return_value = extract_subject_from_return_value(call_implementation)
if after_call_proc
extract_subject_from_return_value(after_call_proc.call(return_value))
Expand Down
1 change: 0 additions & 1 deletion rr.gemspec
Expand Up @@ -97,7 +97,6 @@ Gem::Specification.new do |s|
"lib/rr/wildcard_matchers/range.rb",
"lib/rr/wildcard_matchers/regexp.rb",
"lib/rr/wildcard_matchers/satisfy.rb",
"scratch.rb",
"spec/api/any_instance_of/all_instances_of_spec.rb",
"spec/api/any_instance_of/any_instance_of_spec.rb",
"spec/api/any_instance_of/instance_of_spec.rb",
Expand Down
26 changes: 26 additions & 0 deletions spec/api/stub/stub_spec.rb
Expand Up @@ -123,4 +123,30 @@ def method_missing(method_name, *args, &block)
subject.foobar(4).should == :baz
end
end

context "stub that yields" do
context "when yields called without any arguments" do
it "yields only once" do
called_from_block = mock!.foo.once.subject
block_caller = stub!.bar.yields.subject
block_caller.bar { called_from_block.foo }
end
end

context "when yields called with an argument" do
it "yields only once" do
called_from_block = mock!.foo(1).once.subject
block_caller = stub!.bar.yields(1).subject
block_caller.bar { |argument| called_from_block.foo(argument) }
end
end

context "when yields calls are chained" do
it "yields several times" do
called_from_block = mock!.foo(1).once.then.foo(2).once.subject
block_caller = stub!.bar.yields(1).yields(2).subject
block_caller.bar { |argument| called_from_block.foo(argument) }
end
end
end
end

0 comments on commit 107fd09

Please sign in to comment.