Last active
August 17, 2016 13:54
-
-
Save prakashmurthy/474966b0e2fcab1e4fbd055908dce4e5 to your computer and use it in GitHub Desktop.
Files for adding a new test in rails codebase
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
# activerecord/test/cases/decimal_rounding_test.rb | |
require "cases/helper" | |
require "models/thing" | |
class DecimalRoundingTest < ActiveRecord::TestCase | |
ActiveRecord::Schema.define do | |
create_table :things, force: true do |t| | |
t.decimal :price, precision: 4, scale: 4 | |
end | |
end | |
def test_decimal_rounding | |
thing = Thing.create! | |
thing.price = 0.00001 | |
assert_equal '0.00001', thing.price.to_s | |
end | |
end |
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
# activerecord/test/models/thing.rb | |
class Thing < ActiveRecord::Base | |
end |
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
# Script to run the above test | |
bundle exec ruby -I activerecord/lib:activerecord/test activerecord/test/cases/decimal_rounding_test.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment