Sha256: 656c5ded7217a1956d583b6389cfdb3a8a97375195795c599b1ac7d64217689d
Contents?: true
Size: 1.48 KB
Versions: 39
Compression:
Stored size: 1.48 KB
Contents
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') class ValidateNumericalityOfMatcherTest < ActiveSupport::TestCase # :nodoc: context "a numeric attribute" do setup do define_model :example, :attr => :string do validates_numericality_of :attr end @model = Example.new end should "only allow numeric values for that attribute" do assert_accepts validate_numericality_of(:attr), @model end should "not override the default message with a blank" do assert_accepts validate_numericality_of(:attr).with_message(nil), @model end end context "a numeric attribute with a custom validation message" do setup do define_model :example, :attr => :string do validates_numericality_of :attr, :message => 'custom' end @model = Example.new end should "only allow numeric values for that attribute with that message" do assert_accepts validate_numericality_of(:attr). with_message(/custom/), @model end should "not allow numeric values for that attribute with another message" do assert_rejects validate_numericality_of(:attr), @model end end context "a non-numeric attribute" do setup do @model = define_model(:example, :attr => :string).new end should "not only allow numeric values for that attribute" do assert_rejects validate_numericality_of(:attr), @model end end end
Version data entries
39 entries across 39 versions & 11 rubygems