For some application I am using Paperclip for file upload (actually the dm-paperclip flavour), and Factory Girl, Rspec, Capybara for testing. I have a very simple Factory for the "Picture" model, where I am stubbing my file properties as suggested in this post:
FactoryGirl.define do
factory :picture do
title "My Picasso"
description "It's like looking in a mirror."
picture_file_file_name { 'spec/resources/img_1.jpg' }
picture_file_content_type { 'image/jpg' }
picture_file_file_size { 1024 }
end
end
In diverse feature tests with Capybara, I visit pages in which the templates feature thumbnails of the Picture instances:
feature "List of Pictures", :js => true do
scenario "displays appropriately the index page of the pictures with pagination" do
FactoryGirl.create_list(:picture, 21)
visit '/pictures'
# And more testing...
end
end
An example of partial used in one of the templates:
= content_tag_for(:li, picture, :class => 'listed_picture') do
= link_to picture_path(picture) do
- if picture.picture_file?
= image_tag picture.picture_file.url(:thumb)
The problem I have now, is whenever I run the specs, the test fails because there is no matching route for the thumbnail url:
No route matches [GET] "/system/picture_files/1/thumb/img_1.jpg"
Is there any way to stub Paperclip's helper methods to make the test pass?
Thanks in advance for any help!