Skip to content

Instantly share code, notes, and snippets.

@jqr
Created June 30, 2009 16:34
Show Gist options
  • Save jqr/138260 to your computer and use it in GitHub Desktop.
Save jqr/138260 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
def score=(value)
super(value * 1_000_000) # pinball scores do it, why not Users?
end
end
describe User do
describe "creating a new user" do
it "should multiply the score by some ridiculous amount" do
user = User.new(:score => 5)
user.score.should == 5_000_000
end
end
describe "updating an old user" do
it "should multiply the score by some ridiculous amount" do
user = User.create!
user.update_attributes(:score => 3)
user.score.should == 3_000_000
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment