[rspec-devel] [ rspec-Feature Requests-11949 ] & quot; should_yield& quot; or & quot; .should raise_error(MySpecificError)& quot; equivalent for yields

noreply at rubyforge.org noreply at rubyforge.org
Sun Jul 1 21:27:19 EDT 2007


Feature Requests item #11949, was opened at 2007-07-01 19:49
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=11949&group_id=797

Category: expectation module
Group: None
Status: Open
Priority: 3
Submitted By: S. Potter (mbbx6spp)
Assigned to: Nobody (None)
>Summary: "should_yield" or ".should raise_error(MySpecificError)" equivalent for yields

Initial Comment:
The problem is already described here:
http://snakesgemscoffee.blogspot.com/2007/07/rspec-shouldyield.html

In summary:
Just like we can write:
  lambda { Client.configure(&spec_block(1)) }.should raise_error(MySpecificError)
We should also be able to write:
  lambda { Client.configure(&spec_block(1)) }.should_yield(Config)
This should mean, to the "spec_block" that expects one (1) argument of type Config.

Other suggestions for syntax are:
  lambda { Client.configure(&spec_block(1)) }.should yield_instances_of(Config)
  lambda { Client.configure(&spec_block(1)) }.should yield_objects_of(Config)
Or something else similar (these are just things that popped in my head right now.

Feedback much appreciated.

----------------------------------------------------------------------

>Comment By: S. Potter (mbbx6spp)
Date: 2007-07-01 20:27

Message:
Great thanks, I'll attached to this ticket.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-07-01 20:25

Message:
Cool - I'll keep my eyes peeled for your patch. Go ahead and just attach it to this ticket - no need to make a new patch ticket - OK?

----------------------------------------------------------------------

Comment By: S. Potter (mbbx6spp)
Date: 2007-07-01 20:21

Message:
Actually that sounds great.  I wasn't convinced of my own
suggestions to be honest, just a starting point - wonderful!

I can try coming up with a patch after work days this week,
to contribute back.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-07-01 19:56

Message:
We don't want to add any more "should_xyz" methods because they have to get added directly to object. So it's got to be a matcher - the trick is coming up w/ good verbiage. How about this?

should yield_with(arg1,arg2)
should yield_with(no_args)

You would always have to supply at least one arg - but that arg could be no_args which would be the same method we use for mocks:

should_receive(:message).with(no_args)

WDYT?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=11949&group_id=797


More information about the rspec-devel mailing list