On Dec 18, 2007 11:39 AM, Jonathan Linowes <[EMAIL PROTECTED]> wrote:
>
> hi, i want to make a behavior shared between models, the examples need to
> create new instances etc. Is there a way to pass the model class to the
> shared behavior?
We're calling these shared example groups now.
The way to affect the state within a shared example group is to use
before(:each) to set an instance variable:
shared_examples_for "models that do stuff" do
before(:each) do
@instance = @class.new
end
it "should do something" do
@instance.should do_something
end
end
describe Foo do
before(:each) do
@class = Foo
end
it_should_behave_like "models that do stuff"
end
Cheers,
David
>
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users