Hi Matt, On Wed, Mar 7, 2012 at 2:22 AM, Matt Wynne <m...@mattwynne.net> wrote:
> Hi all, > > I'm spec'ing a method that yields a value. Right now, I spec it like this: > > result = nil > thing.do_stuff { |value| result = value } > result.should == expected > > This feels like too much ceremony. What I want to do is something more > this: > > thing.do_stuff.should yield_value(expected) > > Is there anything built into RSpec to let me do this? If not, how do other > people test yields? > > I came across this about a month or two ago. You can do this: thing.should_receive(:do_stuff).and_yield( whatever) See http://rubydoc.info/gems/rspec-mocks/frames for more details. Regards, Ken
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users