On May 18, 2011, at 11:23 AM, Ken Egervari wrote: > Hello, > > Is there any way to reuse spec definitions, perhaps through some kind of > inheritance? > > For example, in rails, every time it generates a Spec I must tell it to > > 1) Include Devise::TestHelpers > 2) Log the user in, so there is a default user setup before each test is run. > This is common for 95% of my controllers and doesn't seem very DRY to me. > 3) Other types of things that end up requiring setup > > In Java (my main language), I could put all of this in a base class and just > extend it... but I don't know how to do that with a describe block. > > Is there a mechanism for dealing with this? Do I need to include a module > that includes the devise helpers and whatever else I need it to do?
Take a look at shared context: http://relishapp.com/rspec/rspec-core/dir/example-groups/shared-context _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users