JR Boyens
JR Boyens

Reputation: 287

Using Rails test fixture helpers in Cucumber

I'd like to be able to use Rails' test fixture helpers in Cucumber, but the information provided on the Cucumber wiki seems... out of date at best: https://github.com/cucumber/cucumber/wiki/Fixtures (heading: Fixture Helper Methods)

Google has been less than helpful.

Is there a good way to do this?

Update: Tried using ActiveRecord::TestFixtures to no avail it seems like this is the class to do the job, but can't get it mixed into the World correctly

Upvotes: 1

Views: 1563

Answers (2)

Satyaram B V
Satyaram B V

Reputation: 307

After an hour of brain cramming, I was able to make it work. Replace

fix = Fixtures.cached_fixtures(ActiveRecord::Base.connection, table_name)[fixture_symbol.to_s]

with

fix = Fixtures.cached_fixtures(ActiveRecord::Base.connection, table_name).first.fixtures[fixture_symbol.to_s]

I have already updated the wiki at https://github.com/cucumber/cucumber/wiki/Fixtures

Upvotes: 0

Kevin Bedell
Kevin Bedell

Reputation: 13404

One of the reasons there's so little information on fixtures is that most rails developers are now all using Factory Girl to generate test data.

Factory Girl provides you mush more control over both the data that's generated (and when it's created), but it also allows you a lot more control of the associated model classes you inevitably will need.

Upvotes: 1

Related Questions