diff options
Diffstat (limited to 'activemodel/test/cases')
5 files changed, 11 insertions, 8 deletions
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb index 5659dcbc48..c60caf90d7 100644 --- a/activemodel/test/cases/attribute_methods_test.rb +++ b/activemodel/test/cases/attribute_methods_test.rb @@ -31,7 +31,7 @@ class AttributeMethodsTest < ActiveModel::TestCase ModelWithAttributes.define_attribute_methods([:foo]) assert ModelWithAttributes.attribute_methods_generated? - assert ModelWithAttributes.new.respond_to?(:foo) + assert_respond_to ModelWithAttributes.new, :foo assert_equal "value of foo", ModelWithAttributes.new.foo end diff --git a/activemodel/test/cases/callbacks_test.rb b/activemodel/test/cases/callbacks_test.rb index b996f51d6b..9675b5d450 100644 --- a/activemodel/test/cases/callbacks_test.rb +++ b/activemodel/test/cases/callbacks_test.rb @@ -65,6 +65,6 @@ class CallbacksTest < ActiveModel::TestCase test "only selects which types of callbacks should be created" do assert !ModelCallbacks.respond_to?(:before_initialize) assert !ModelCallbacks.respond_to?(:around_initialize) - assert ModelCallbacks.respond_to?(:after_initialize) + assert_respond_to ModelCallbacks, :after_initialize end end diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb index c910cb43d4..e1a35be384 100644 --- a/activemodel/test/cases/dirty_test.rb +++ b/activemodel/test/cases/dirty_test.rb @@ -22,8 +22,8 @@ class DirtyTest < ActiveModel::TestCase test "changes accessible through both strings and symbols" do model = DirtyModel.new model.name = "David" - assert !model.changes[:name].nil? - assert !model.changes['name'].nil? + assert_not_nil model.changes[:name] + assert_not_nil model.changes['name'] end end diff --git a/activemodel/test/cases/serializeration/xml_serialization_test.rb b/activemodel/test/cases/serializeration/xml_serialization_test.rb index 4e8e4efa25..ff786658b7 100644 --- a/activemodel/test/cases/serializeration/xml_serialization_test.rb +++ b/activemodel/test/cases/serializeration/xml_serialization_test.rb @@ -17,6 +17,9 @@ module Admin end end +class Customer < Struct.new(:name) +end + class XmlSerializationTest < ActiveModel::TestCase def setup @contact = Contact.new @@ -24,7 +27,7 @@ class XmlSerializationTest < ActiveModel::TestCase @contact.age = 25 @contact.created_at = Time.utc(2006, 8, 1) @contact.awesome = false - customer = OpenStruct.new + customer = Customer.new customer.name = "John" @contact.preferences = customer end @@ -69,7 +72,7 @@ class XmlSerializationTest < ActiveModel::TestCase test "should allow skipped types" do @xml = @contact.to_xml :skip_types => true - assert %r{<age>25</age>}.match(@xml) + assert_match %r{<age>25</age>}, @xml end test "should include yielded additions" do @@ -104,7 +107,7 @@ class XmlSerializationTest < ActiveModel::TestCase end test "should serialize yaml" do - assert_match %r{<preferences type=\"yaml\">--- !ruby/object:OpenStruct \ntable:\s*:name: John\n</preferences>}, @contact.to_xml + assert_match %r{<preferences type=\"yaml\">--- !ruby/struct:Customer \nname: John\n</preferences>}, @contact.to_xml end test "should call proc on object" do diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb index be620c53fa..8e77a0222e 100644 --- a/activemodel/test/cases/validations/numericality_validation_test.rb +++ b/activemodel/test/cases/validations/numericality_validation_test.rb @@ -18,7 +18,7 @@ class NumericalityValidationTest < ActiveModel::TestCase FLOATS = [0.0, 10.0, 10.5, -10.5, -0.0001] + FLOAT_STRINGS INTEGERS = [0, 10, -10] + INTEGER_STRINGS BIGDECIMAL = BIGDECIMAL_STRINGS.collect! { |bd| BigDecimal.new(bd) } - JUNK = ["not a number", "42 not a number", "0xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"] + JUNK = ["not a number", "42 not a number", "0xdeadbeef", "0xinvalidhex", "0Xdeadbeef", "00-1", "--3", "+-3", "+3-1", "-+019.0", "12.12.13.12", "123\nnot a number"] INFINITY = [1.0/0.0] def test_default_validates_numericality_of |