[rspec-users] Getting Class in Shared Behaviours

Scott Taylor mailing_lists at railsnewbie.com
Wed Nov 21 23:25:31 EST 2007

On Nov 21, 2007, at 11:14 PM, Ben Mabey wrote:

> I like what Scott suggested.
> it_should_behave_like "a foo", :with => { ... }
> Might read a little better.  But I like the idea of it just taking  
> a hash.

The obvious problem with this approach is that it will crowd the  
namespace (declaring methods in the shared example object might lead  
to some hard to track down bugs).

The other suggestion, as proposed in IRC (for those who may not have  
been in the room).

[11:06pm] smtlaissezfaire: So I was thinking of another way to do  
this - with the shared specs
[11:06pm] fowlduck: elaborate
[11:06pm] smtlaissezfaire: It could be block/lambda based
[11:06pm] fowlduck: that's actually what I was going to suggest
[11:06pm] smtlaissezfaire: So you might say it_should_behave_like  
"foo", var1, var2 and so on
[11:07pm] fowlduck: *args, &proc
[11:07pm] fowlduck: or something
[11:07pm] smtlaissezfaire: and then describe "a shared  
example", :shared => true do |var1, var2|

I'm interested in other's opinions (or other suggestions).


More information about the rspec-users mailing list