On 23 Feb 2010, at 17:30, Scott Taylor wrote:
Has there been any development on shared helpers /
it_should_behave_like feature in rspec?
I forget the reasons, but I remember a patch for something like this
was rejected:
it_should_behave_like "an_entry", :locals => { :entry =>
Entry.new }
OR:
before do
@entry = Entry.new
end
it_should_behave_like "an_entry", :locals => lambda {
{
:entry => @entry
}
}
Is there any code which now deals with the variable passing issue in
rspec?
Best,
Scott
FWIW, what I've done in this situation is expect that the ExampleGroup
I've mixed the shared behaviour into to define a method, and call that
from the shared examples - if it's not defined you'll find out pretty
quickly. Another approach is to just expect the @variable to be set:
describe "an entry" do
before
@entry or raise("You need to set @entry to use this shared
example group")
end
end
It's not great, but it makes the shared example group a little more
self-documenting than if you just shared the instance variable without
the check.
cheers,
Matt
http://mattwynne.net
+447974 430184
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users