spec/support/fake_helper.rb in cfoundry-0.5.0 vs spec/support/fake_helper.rb in cfoundry-0.5.1.rc1

- old
+ new

@@ -77,11 +77,11 @@ def get_many(plural) @cache[plural] end def fake_attributes(attributes) - fakes = default_fakes.merge(attributes) + fakes = default_fakes # default relationships to other fake objects self.class.to_one_relations.each do |name, opts| # remove _guid (not an actual attribute) fakes.delete :"#{name}_guid" @@ -92,9 +92,20 @@ opts[:default] else @client.send(opts[:as] || name).fake end end + + # make sure that the attributes provided are set after the defaults + # + # we have to do this for cases like environment_json vs. env, + # where one would clobber the other + attributes.each do |k, _| + fakes.delete k + end + + fakes = fakes.to_a + fakes += attributes.to_a fakes end # override this to provide basic attributes (like name) dynamically