Title says it all. I'm setting my EmbeddedValue associations to mocha Mock classes. My virtus classes look like this:
class Todo
include Virtus
attribute :user, User
end
Then some where in a test:
todo = Todo.new
todo.user = mock
This causes errors because coerce is still set and the Mock objects are being coerced via to_hash. Which is of course is an undefined method / unstubbed message blowing things up.
The documentation says you can set Virtus::Attribute.coerce false to disable this. This not entirely the case. The flag must also be set of on Virtus::Attribute::EmbeddedValue.
Title says it all. I'm setting my
EmbeddedValue
associations to mochaMock
classes. My virtus classes look like this:Then some where in a test:
This causes errors because
coerce
is still set and theMock
objects are being coerced viato_hash
. Which is of course is an undefined method / unstubbed message blowing things up.The documentation says you can set
Virtus::Attribute.coerce false
to disable this. This not entirely the case. The flag must also be set of onVirtus::Attribute::EmbeddedValue
.This makes my test suite work as expected: