[rspec-users] fixture_file_upload and edge rspec?

Leslie Freeman leslief at sunquake.net
Fri Nov 9 10:25:04 EST 2007


On Nov 9, 2007, at 5:09 AM, David Chelimsky wrote:

> On Nov 8, 2007 11:25 PM, Leslie Freeman <lesliefreeman3 at gmail.com>  
> wrote:
>> Hi all,
>> I had some specs that were using fixture_file_upload that were
>> passing just fine. Then I froze edge rails to get some 2.0
>> functionality, then a I upgraded to trunk rspec to deal with
>>
>> uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper
>>
>> After a couple other of tribulations, I have now gotten down to just
>> a couple of not passing specs, all using the fixture_file_upload.
>> Here's an example
>>
>> it "should be invalid if uploaded file is not an image" do
>>      @image.attributes = valid_image_attributes.merge({:uploaded_data
>> => fixture_file_upload('/textfile.txt',
>>
>>                       'text/plain')})
>>      @image.should_not be_valid
>>      # content_type: is not included in the list
>>      @image.should have(1).error_on(:content_type)
>> end
>>
>> which fails with:
>> 2)
>> NoMethodError in 'Image unsaved should be invalid if uploaded file is
>> not an image'
>> You have a nil object when you didn't expect it!
>> You might have expected an instance of Array.
>> The error occurred while evaluating nil.+
>> ./spec/models/image_spec.rb:25:
>
> What's on line 25?

Sorry about that confusion. Line 25 is:

@image.attributes = valid_image_attributes.merge({:uploaded_data =>  
fixture_file_upload('/textfile.txt',text/plain')})

(textfile.txt is located in my /spec/fixtures/ dir.)

That line doesn't throw the error if I change it to something like:
@image.attributes = valid_image_attributes.merge({:uploaded_data =>  
"foo"})

But of course the spec fails. :)

Leslie

>
>>
>> A less than helpful error message. Any insight into what might be
>> causing this?
>>
>> Thanks,
>> Les
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list