Created
February 15, 2010 18:21
-
-
Save mdeering/304857 to your computer and use it in GitHub Desktop.
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
#... | |
# Added in your example and it passed without your pull request. | |
describe 'will perform its actions before type cast' do | |
before do | |
User.class_eval do | |
normalize_attribute :price do |value| | |
value.to_s.gsub(",",".").to_f | |
end | |
end | |
end | |
{ '44,8' => 44.8 }.each do |key, value| | |
it "should normalize '#{key}' to '#{value}'" do | |
user = User.new(:price => key) | |
user.price.should == value | |
end | |
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
#... | |
# Added in the price column | |
ActiveRecord::Schema.define do | |
create_table :users, :force => true do |t| | |
t.string :name | |
t.float :price | |
end | |
end | |
#... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment