Sha256: 80ef75ee7d96a17298c002b757cb0b0e37bc43fcdc81823caa61070a29c38336
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' require 'integration/numeric_validator/spec_helper' describe DataMapper::Validate::Fixtures::BasketballPlayer do before :all do @model = DataMapper::Validate::Fixtures::BasketballPlayer.new(:name => "Michael Jordan", :height => 198.1, :weight => 97.2) end describe "with height as float" do before :all do # no op in this case end it_should_behave_like "valid model" end describe "with height as integer" do before :all do @model.height = 198 end it_should_behave_like "valid model" end describe "with height as string containing only integers" do before :all do @model.height = "198" end it_should_behave_like "valid model" end describe "with height as string containing a float" do before :all do @model.height = "198.1" end it_should_behave_like "valid model" end describe "with height as string containing a float that will be represented in scientific notation" do before :all do @model.height = '0.00004' end it_should_behave_like "valid model" end describe "with height as string containing random alphanumeric characters" do before :all do @height = 'height=198.1' @model.height = "height=198.1" end it "is should not change the value" do @model.height.should == @height end it_should_behave_like "invalid model" end describe "with height as string containing random punctuation characters" do before :all do @height = '$$ * $?' @model.height = @height end it "is should not change the value" do @model.height.should == @height end it_should_behave_like "invalid model" end describe "with nil height" do before :all do @model.height = nil @model.valid? end # typecasting kicks in it_should_behave_like "invalid model" it "has a meaningful error message" do @model.errors.on(:height).should == [ 'Height must be a number' ] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-validations-0.10.1 | spec/integration/numeric_validator/float_type_spec.rb |
dm-validations-0.10.0 | spec/integration/numeric_validator/float_type_spec.rb |