Browse files

just construct real objects rather than mock and stub

  • Loading branch information...
1 parent 750077a commit 8442ec313cf767e872acdf02fe8c02efe96ea34d @tenderlove tenderlove committed Jun 17, 2013
Showing with 8 additions and 7 deletions.
  1. +8 −7 activerecord/test/cases/attribute_methods/serialization_test.rb
View
15 activerecord/test/cases/attribute_methods/serialization_test.rb
@@ -8,20 +8,21 @@ def type; :integer; end
def type_cast(s); "#{s}!"; end
end
- def test_type_cast_serialized_value
- value = stub(state: :serialized, value: "Hello world")
- value.expects(:unserialized_value).with("Hello world!")
+ class NullCoder
+ def load(v); v; end
+ end
+ def test_type_cast_serialized_value
+ value = Serialization::Attribute.new(NullCoder.new, "Hello world", :serialized)
type = Serialization::Type.new(FakeColumn.new)
- type.type_cast(value)
+ assert_equal "Hello world!", type.type_cast(value)
end
def test_type_cast_unserialized_value
- value = stub(state: :unserialized, value: "Hello world")
- value.expects(:unserialized_value).with()
-
+ value = Serialization::Attribute.new(nil, "Hello world", :unserialized)
type = Serialization::Type.new(FakeColumn.new)
type.type_cast(value)
+ assert_equal "Hello world", type.type_cast(value)
end
end
end

0 comments on commit 8442ec3

Please sign in to comment.