Created
February 8, 2013 09:49
-
-
Save nordringrayhide/4737788 to your computer and use it in GitHub Desktop.
factory girl build_stubbed example
This file contains hidden or 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
class User < ActveRecord::Base | |
def full_name | |
"#{ last_name } #{ first_name }" | |
end | |
end | |
describe User do | |
# in this case a real AR object needless | |
# profit => speed up, more test isolation(test does not fail when database connection is broken) | |
it "should return full_name like combine last_name && first_name" do | |
user = build_stubbed(:user, :last_name => 'Doe', :first_name => 'John') | |
user.full_name.should eql 'Doe John' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment