Skip to content

Instantly share code, notes, and snippets.

@johndavid400
Created July 21, 2011 15:53
Show Gist options
  • Save johndavid400/1097495 to your computer and use it in GitHub Desktop.
Save johndavid400/1097495 to your computer and use it in GitHub Desktop.
Using with factory-girl or machinist
But you’re using Machinist or FactoryGirl right?! To leverage all of the factories/blueprints you’ve written, you can just do stuff like
Given a user exists
And another user exists with role: "admin"
# later
Then a user should exist with name: "Fred"
And that user should be activated # this uses rspec predicate matchers
Machinist: require your blueprints and reset Shams
In your features/support/env.rb add the following lines at the bottom
require "#{Rails.root}/spec/blueprints" # or wherever they live
Before { Sham.reset } # reset Shams in between scenarios
FactoryGirl: make sure factories are loaded
In your config/environments/cucumber.rb file, make sure the factory-girl gem is included (unless it’s installed as a plugin).
If that doesn’t solve loading issues then require your factories.rb file directly in a file called ‘features/support/factory_girl.rb’
# example features/support/factory_girl.rb
require File.dirname(__FILE__) + '/../../spec/factories'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment