How does one write a Factory Girl definition for a Mongoid class where one of the properties is a hash? (it is not an embedded document)
The Mongoid class looks something such as
class Foo
field :bar, :type => Hash
end
so an instance of Foo should be able to access bar via foo.bar['foobar'] = 1
This cannot be depicted in a Factory Girl definition though by doing something like:
Factory.define :foo do |f|
f.bar {:foobar => 1}
end
I don’t know FactoryGirl, but I’d guess that Ruby is interpreting the curly brackets as a block. This should work: