Created
March 11, 2015 08:36
-
-
Save a-suenami/c62320df6a2efefff313 to your computer and use it in GitHub Desktop.
Factorygirl sample
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
FactoryGirl.define do | |
factory :model_name do | |
name "Name" | |
description "Description" | |
registered_at Time.zone.now | |
end | |
end |
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
describe ModelName do | |
describe "Test of name" do | |
it "should have getter of name." do | |
sut = FactoryGirl.create(:model_name, name: 'name for test') | |
expect(sut.name).to eq 'name for test' | |
end | |
end | |
describe "Test of registered_at" do | |
describe '#new' do | |
it "should be new within 7 days from registration." do | |
sut = FactoryGirl.create(:model_name, registered_at: Time.zone.now - 6.day) | |
expect(sut.new).to eq true | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment