# Scenarios Plugin Pre-Announcement

**URL:** <https://www.ruby-forum.com/t/scenarios-plugin-pre-announcement/117560>\
**Category:** RSpec\
**Created:** [October 18, 2007, 3:02am UTC](https://www.ruby-forum.com/t/scenarios-plugin-pre-announcement/117560 "2007-10-18T03:02:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [October 18, 2007, 3:02am UTC](https://www.ruby-forum.com/t/scenarios-plugin-pre-announcement/117560/1 "2007-10-18T03:02:21Z")

</div>

On 10/17/07, Scott T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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  
Scenario:

class PeopleScenario \< Scenario::Base  
def load  
create\_person :name =\> “John”  
end

helpers do  
def create\_person(attributes={})  
create\_record :person, attributes[:name].downcase.intern,  
attributes  
end  
def login\_as(person)  
# insert person into session  
end  
end  
end

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  
login\_as(people(:john))  
# verify that the correct projects are showing  
end  
end

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

[http://faithfulcode.rubyforge.org/svn/plugins/trunk/scenarios/spec/scenarios\_spec.rb](http://faithfulcode.rubyforge.org/svn/plugins/trunk/scenarios/spec/scenarios_spec.rb)

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
