Permalink
Browse files

just construct real objects rather than mock and stub

  • Loading branch information...
1 parent 252d113 commit e086ff563569f72a156fe105cc47767ad376cc3f @tenderlove tenderlove committed Jun 17, 2013
Showing with 8 additions and 7 deletions.
  1. +8 −7 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

1 comment on commit e086ff5

Contributor

mrbrdo commented on e086ff5 Jun 17, 2013

I would have, but I was too lazy to find out what the input was. :) Since I'm here, have you seen this comment #10830 (comment) he said this patch did not solve his issue (even though he found a different workaround later). It sounds mildly related and it seems it's a regression in rc2.

Error I had: "wrong argument type Hash (expected String)"
Error he has/had: TypeError: no implicit conversion of Hash into String

Please sign in to comment.