lib/test_dummy.rb in test_dummy-0.1.3 vs lib/test_dummy.rb in test_dummy-0.1.4

- old
+ new

@@ -37,11 +37,11 @@ Helper.send(:extend, new_module) end # Used in an initializer to define things that can be dummied by all # models if these properties are available. - def self.to_dummy(*names, &block) + def self.dummy(*names, &block) case (names.last) when Hash options = names.pop end @@ -74,11 +74,11 @@ # Declares how to fake one or more attributes. Accepts a block # that can receive up to two parameters, the first the instance of # the model being created, the second the parameters supplied to create # it. The first and second parameters may be nil. - def to_dummy(*names, &block) + def dummy(*names, &block) options = nil case (names.last) when Hash options = names.pop @@ -153,11 +153,11 @@ model end # Produces dummy data for a single attribute. - def dummy(name, with_attributes = nil) + def dummy_attribute(name, with_attributes = nil) with_attributes = TestDummy.combine_attributes(scoped.scope_for_create, with_attributes) dummy_method_call(nil, with_attributes, dummy_method(name)) end @@ -184,9 +184,11 @@ end # This performs the dummy operation on a model with an optional set # of parameters. def execute_dummy_operation(model, with_attributes = nil) + return model unless (@test_dummy_order) + @test_dummy_order.each do |name| if (reflection = reflect_on_association(name)) unless ((with_attributes and with_attributes.key?(name.to_sym)) or model.send(name)) model.send(:"#{name}=", dummy_method_call(model, with_attributes, dummy_method(name))) end