Skip to content
This repository
Browse code

just construct real objects rather than mock and stub

  • Loading branch information...
commit 8442ec313cf767e872acdf02fe8c02efe96ea34d 1 parent 750077a
Aaron Patterson tenderlove authored
15 activerecord/test/cases/attribute_methods/serialization_test.rb
@@ -8,20 +8,21 @@ def type; :integer; end
8 8 def type_cast(s); "#{s}!"; end
9 9 end
10 10
11   - def test_type_cast_serialized_value
12   - value = stub(state: :serialized, value: "Hello world")
13   - value.expects(:unserialized_value).with("Hello world!")
  11 + class NullCoder
  12 + def load(v); v; end
  13 + end
14 14
  15 + def test_type_cast_serialized_value
  16 + value = Serialization::Attribute.new(NullCoder.new, "Hello world", :serialized)
15 17 type = Serialization::Type.new(FakeColumn.new)
16   - type.type_cast(value)
  18 + assert_equal "Hello world!", type.type_cast(value)
17 19 end
18 20
19 21 def test_type_cast_unserialized_value
20   - value = stub(state: :unserialized, value: "Hello world")
21   - value.expects(:unserialized_value).with()
22   -
  22 + value = Serialization::Attribute.new(nil, "Hello world", :unserialized)
23 23 type = Serialization::Type.new(FakeColumn.new)
24 24 type.type_cast(value)
  25 + assert_equal "Hello world", type.type_cast(value)
25 26 end
26 27 end
27 28 end

0 comments on commit 8442ec3

Please sign in to comment.
Something went wrong with that request. Please try again.