[rspec-users] shared behav
dchelimsky at gmail.com
Tue Dec 18 16:36:40 EST 2007
On Dec 18, 2007 11:39 AM, Jonathan Linowes <JONATHAN at linowes.com> 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
@instance = @class.new
it "should do something" do
describe Foo do
@class = Foo
it_should_behave_like "models that do stuff"
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users