Skip to content

Instantly share code, notes, and snippets.

@dlchet
Created December 6, 2011 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlchet/1439759 to your computer and use it in GitHub Desktop.
Save dlchet/1439759 to your computer and use it in GitHub Desktop.
# can be found in features/support/env.rb
require 'pp'
require 'features/support/user'
require 'factory_girl_rails'
# can be found in features/support/factories.rb
FactoryGirl.define do
factory :user do
name 'Adam Advertiser'
email 'a@b.com'
end
end
pp FactoryGirl.create(:user)
require 'factory_girl/step_definitions'
$ rbenv exec cucumber
"Adam Advertiser"
"a@b.com"
#<User:0x101967808 @email="a@b.com", @name="Adam Advertiser">
Feature: a
Scenario: test factory-girl # features/user.feature:2
"Brandon"
"brandon@example.com"
Given the following user exists: # factory_girl-2.3.2/lib/factory_girl/step_definitions.rb:100
| name | email |
| Brandon | brandon@example.com |
1 scenario (1 passed)
1 step (1 passed)
0m0.004s
# can be found in features/user.feature
Feature: a
Scenario: test factory-girl
Given the following user exists:
| name | email |
| Brandon | brandon@example.com |
# can be found in features/support/user.rb
class User
attr_accessor :name, :email
def save!
pp @name
pp @email
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment