Skip to content

Instantly share code, notes, and snippets.

@nordringrayhide
Created February 8, 2013 09:49
Show Gist options
  • Save nordringrayhide/4737788 to your computer and use it in GitHub Desktop.
Save nordringrayhide/4737788 to your computer and use it in GitHub Desktop.
factory girl build_stubbed example
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