[rspec-users] Cucumber and fixtures/FixtureReplacement

Tim Glen tim at pivotib.com
Tue Sep 9 14:20:16 EDT 2008

> On Tue, Sep 9, 2008 at 7:45 PM, Matt Wynne <matt at mattwynne.net> wrote:
>> Remember these things should use transactions, and may do that by  
>> default -
>> the database will be wiped clean once the features have run.

sorry - I wasn't trying to say that the database is empty after the  
scenarios are run, but that the specific fixtures or  
FixtureReplacements aren't in the db during the scenario. I'm basing  
that on doing Model.find(...) calls right in the steps file.

> FWIW, When Cucumber is used with Rails it runs all scenarios in a  
> transaction.
> I haven't tried FixtureReplacement, but it should work just fine in
> Given steps. I think you'd just have to make sure you mix in the
> FixtureReplacement module in your "world". Put this in your
> steps/env.rb and let us know how it works:
> Before do
>  self.extend(FixtureReplacement)
> end

I had previously tried this right in the steps file:
Before do

That resulted in an "undefined method `create_project'" exception.  
Trying what you suggest above (both in the env.rb file or the steps  
file) results in the same exception:

     Given that I am on the new project investment page
       undefined method `create_project' for  
#<ActionController::Integration::Session:0x43b0a5c> (NoMethodError)
action_controller/test_process.rb:464:in `method_missing'
plugins/rspec/lib/spec/matchers.rb:149:in `method_missing'
plugins/webrat/lib/webrat/rails/session.rb:26:in `method_missing'
action_controller/integration.rb:448:in `send!'
action_controller/integration.rb:448:in `method_missing'
       ./features/steps/cart_steps.rb:8:in `Given /I am on the new  
project investment page/'
       features/cart.feature:36:in `Given that I am on the new project  
investment page'
Tim Glen
tim at pivotib.com
Rails v2.0.2
RSpec v1.1.4

More information about the rspec-users mailing list