Cucumber and fixtures/FixtureReplacement

Hey guys,

I’d never used RSpec Stories before, so I decided to follow the
apparent direction of the wind and just jump right into cucumber. I’m
dabbling with/using Cucumber and really like it. Good job, aslak!

Where i’m struggling right now is using either fixtures or a model
factory methodology like the FixtureReplacement. In both cases, I’m
not seeing anything getting loaded into the database.

I have some legacy fixtures that I’m willing to let go of, but I kind
of assumed that they would work for now. When I run my Features, I’m
not seeing anything whatsoever loaded into the db.

When I use FixtureReplacement (http://replacefixtures.rubyforge.org/),
i’m getting errors that the methods aren’t defined. I’ve added a
“config.include FixtureReplacement” to my spec_helper but that didn’t
seem to make any difference. Then I tried adding “include
FixtureReplacement” into my Steps Before block, but that doesn’t work
either.

any thoughts?

Tim G.
Rails 2.0.2
RSpec 1.1.4

Remember these things should use transactions, and may do that by
default - the database will be wiped clean once the features have run.

On 9 Sep 2008, at 18:22, Tim G. wrote:

I have some legacy fixtures that I’m willing to let go of, but I
any thoughts?

Tim G.
Rails 2.0.2
RSpec 1.1.4


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

cheers,
Matt

http://blog.mattwynne.net
http://songkick.com

In case you wondered: The opinions expressed in this email are my own
and do not necessarily reflect the views of any former, current or
future employers of mine.

On Tue, Sep 9, 2008 at 7:45 PM, Matt W. [email protected] wrote:

Remember these things should use transactions, and may do that by default -
the database will be wiped clean once the features have run.

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

Aslak

On 9 Sep 2008, at 18:22, Tim G. wrote:

Hey guys,

I’d never used RSpec Stories before, so I decided to follow the apparent
direction of the wind and just jump right into cucumber. I’m dabbling
with/using Cucumber and really like it. Good job, aslak!

Thanks!

FixtureReplacement" to my spec_helper but that didn’t seem to make any
The spec helper doesn’t influence cucumber

difference. Then I tried adding “include FixtureReplacement” into my Steps

In Ruby - include is for classes/modules. Use extend to mix in a
module in an object. See above.

HTH,
Aslak

Before do
self.extend(FixtureReplacement)
end

I had previously tried this right in the steps file:
Before do
self.include(FixtureReplacement)
end

Actually - this turned out to almost the right thing. I just added
this to my env.rb:
include FixtureReplacement

Wrapping it in the Before block didn’t work. Removing it from the
block did.

take care,
tim

On Tue, Sep 9, 2008 at 7:45 PM, Matt W. [email protected] 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.

end
I had previously tried this right in the steps file:
Before do
self.include(FixtureReplacement)
end

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)
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/test_process.rb:464:in method_missing' /Users/tim/projects/donortrust/branches/1-3-development/vendor/ plugins/rspec/lib/spec/matchers.rb:149:inmethod_missing’
/Users/tim/projects/donortrust/branches/1-3-development/vendor/
plugins/webrat/lib/webrat/rails/session.rb:26:in method_missing' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/integration.rb:448:insend!’
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/integration.rb:448:in method_missing' ./features/steps/cart_steps.rb:8:inGiven /I am on the new
project investment page/’
features/cart.feature:36:in `Given that I am on the new project
investment page’

Tim G.
[email protected]
Rails v2.0.2
RSpec v1.1.4

Did you see that my code uses extend?

Yes - tried both in my flailing about :slight_smile:

If that still doesn’t work, file a bug report.
http://rspec.lighthouseapp.com/projects/16211-cucumber/overview

It might be a FixtureReplacement bug, but I’ll still look into it.

Could it be that FixtureReplacement is generating methods on the fly,
so to speak?

given that it works when I just `include’ it, is it still a bug?

thanks,
tim

On Tue, Sep 9, 2008 at 8:20 PM, Tim G. [email protected] wrote:

Model.find(…) calls right in the steps file.

self.extend(FixtureReplacement)
end

I had previously tried this right in the steps file:
Before do
self.include(FixtureReplacement)
end

Did you see that my code uses extend?

If that still doesn’t work, file a bug report.
http://rspec.lighthouseapp.com/projects/16211-cucumber/overview

It might be a FixtureReplacement bug, but I’ll still look into it.

fly, so to speak?

Maybe

given that it works when I just `include’ it, is it still a bug?

What? Is it working? Or not? Confused. File a bug if nothing you do
makes it work.

On Sep 9, 2008, at 2:58 PM, Tim G. wrote:

fly, so to speak?

given that it works when I just `include’ it, is it still a bug?

Yeah - it’s a module, but it does generate the methods only when
included (see the following gist: http://gist.github.com/9801)

I believe that Module does has an hook mechanism for extending, as
well (Module#extended) - so I’ll look into doing that. Feel free to
file a bug report on rubyforge:

http://rubyforge.org/tracker/?group_id=4556&atid=17542

Scott

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs