Hi, I have this code:

  def self.bulk_create_from_holly( params )
    params.map do |param|
      new( param )
    end
  end

That is testeb by this expectation:

    it "should generate a new property with each set of params" do
      [ @params, @properties ].transpose.each do |(param, property)|
        Property.should_receive( :new ).with( param ).and_return( property )
      end

      do_call
    end

In it, @params and @properties are of the same size (they are generated
together). The objects in the @properties array are not mocked active record
objects, but just plain old mocks (ie. mock( property1 ) ). This has to be
so, as I am using a third party ar adapter that does not support the rails
spec stubs & mocks.
In the spec, I am simply trying to assert that a new property should be
generated for each item in @params.
However, I am getting this message when I run the expectation:

NoMethodError in 'Property.bulk_create_from_holly( params ) should generate
a new property with each set of params'
undefined method `size' for #<Proc:0xb72721b4@
./spec/models/property_spec.rb:49>
/home/doug/work/rails/neville/app/models/property.rb:20:in
`bulk_create_from_holly'
/home/doug/work/rails/neville/app/models/property.rb:19:in `map'
/home/doug/work/rails/neville/app/models/property.rb:19:in
`bulk_create_from_holly'
./spec/models/property_spec.rb:38:in `do_call'
./spec/models/property_spec.rb:52:
./script/spec:10:

As you can see, nowhere do I call size(), and so can only think that this is
some bizarre internal thing.
Or I'm being really dumb & missing something obvious.
Can anyone spot where I'm going wrong, or maybe suggest a way around this?
Cheers,
   Doug.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to