[rspec-users] Scenarios Plugin Pre-Announcement

John Long johnwlong2000 at gmail.com
Wed Oct 17 21:01:47 EDT 2007

On 10/17/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> I haven't had the chance to really play with your plugin.  How is it
> different than fixture scenarios (from err.the.blog)?

I haven't actually used err.the.blog's plugin, though ours certainly
draws heavily upon it for inspiration.

>From what I can tell both plugins provide the following:

1. Code based data population
2. Grouping of data population methods through "scenarios"
3. Dependencies between scenarios so that you can declare that one
scenario requires another to be loaded first

One key difference between the two plugins is that err.the.blog's
approach depends on your models being in place and creates new records
using your models. This means that your scenario data must run through
validations before it can be inserted into the database. This can be
slow. Our approach encourages you to inject data straight into the
database in much the same way that fixtures do it. We believe this is
a better approach.

One thing that our approach adds over err.the.blog's is the idea of
Scenario helpers. To use scenario helpers you declare them inside a

class PeopleScenario < Scenario::Base
  def load
    create_person :name => "John"

  helpers do
    def create_person(attributes={})
      create_record :person, attributes[:name].downcase.intern, attributes
    def login_as(person)
      # insert person into session

Helper methods declared inside the helpers block are mixed into the
scenario (so you can access them in the load method) and into the
Rspec behavior:

describe "Projects screen" do
  scenario :people

  it "should show active projects" do
    # verify that the correct projects are showing

For more examples I'd highly encourage you to look through the specs:


John Long

More information about the rspec-users mailing list