Your implementation looks so much like a ModelFactory my team
implemented last week that it's scary. Anyway ...
Is it a typo that you show the "create_..." methods being def'd as
module methods (i.e., "def self.create...") while the
"valid_..._attribute" methods are instance methods? That would
certainly cause NoMethodErrors (though it would affect specs as well
as other contexts).
-hume.
On Jan 10, 2008 8:27 PM, James Deville <[EMAIL PROTECTED]> wrote:
> We have a custom implementation of the Mother Object idea. It's inside
> of a module, basically like this:
>
> module Factory
> %w(account friendship person invitation message asset email_address
> birth).each do |klass|
> eval <<-EOF
> def self.create_#{klass}(attributes = {})
> default_attributes = valid_#{klass}_attributes
> #{klass.camelize}.create!
> default_attributes.merge(attributes)
> end
> EOF
> end
>
> def valid_message_attributes(options = {})
> {
> #some message options
> }
> end
>
> #more valid_x_attributes methods
> end
>
> When I require this file in a spec file, Factory.create_person works
> fine. When I try to do it in a step file, Factory.create_person is
> defined, but it fails because valid_person_attributes is missing. If
> I'm in a debugger, and I do require 'model_factory' followed by
> Factory.create_person, same deal.
>
> Do we have a blank slate being loaded somewhere, and why is it wiping
> out require files?
>
> Thanks
>
> James Deville
> http://devillecompanies.org
> [EMAIL PROTECTED]
> rspec r3172
> rspec_on_rails r3172
> rails r8331
>
>
>
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users