Getting Class in Shared Behaviours

On Nov 21, 2007, at 11:14 PM, Ben M. 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).

Scott

Bah, I won’t have time to do this anytime soon, you can feel free,
Scott.

Nathan S.
[email protected]
rspec edge revision 2944
rspec_on_rails edge revision 2944
rails edge revision 8186