Created
December 6, 2011 20:12
-
-
Save dlchet/1439759 to your computer and use it in GitHub Desktop.
factory girl + cucumber simple test (from http://stackoverflow.com/questions/8397420/factory-girl-rails-cucumberundefined/8398156#8398156)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# can be found in features/support/env.rb | |
require 'pp' | |
require 'features/support/user' | |
require 'factory_girl_rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# can be found in features/support/factories.rb | |
FactoryGirl.define do | |
factory :user do | |
name 'Adam Advertiser' | |
email '[email protected]' | |
end | |
end | |
pp FactoryGirl.create(:user) | |
require 'factory_girl/step_definitions' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rbenv exec cucumber | |
"Adam Advertiser" | |
"[email protected]" | |
#<User:0x101967808 @email="[email protected]", @name="Adam Advertiser"> | |
Feature: a | |
Scenario: test factory-girl # features/user.feature:2 | |
"Brandon" | |
"[email protected]" | |
Given the following user exists: # factory_girl-2.3.2/lib/factory_girl/step_definitions.rb:100 | |
| name | email | | |
| Brandon | [email protected] | | |
1 scenario (1 passed) | |
1 step (1 passed) | |
0m0.004s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# can be found in features/user.feature | |
Feature: a | |
Scenario: test factory-girl | |
Given the following user exists: | |
| name | email | | |
| Brandon | [email protected] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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