Paperclip + Cucumber + Webrat - brak uploadu w testach

Witam wszystkich,

W projekcie posiadam prosty model Photo, z podłączonym plikiem przez papercut:

[code]class Photo < ActiveRecord::Base
belongs_to :gate
validates_presence_of :gate
before_destroy :delete_image

has_attached_file :image, :styles => {:medium => “300x100>”, :thumb => “100x100>”, :main => “800x800>”}
validates_attachment_presence :image
validates_attachment_content_type :image, :content_type => “image/jpeg”

def delete_image
self.image.nil
end
end[/code]
wraz z równie prostym kontrolerem:

[code]class PhotosController < ApplicationController
before_filter :find_gate
def new
@photo = @gate.photos.new
end

def create
p params[:photo]
@photo = @gate.photos.new params[:photo]
if @photo.save
flash[:notice] = “Photo added.”
redirect_to gate_photos_path(@gate)
else
render “new”
end
end

def edit
end

def index
@photos = @gate.photos
end

def show
end

def find_gate
@gate = Gate.find(params[:gate_id])
end
end[/code]
i formę do niego (formtastic):

- semantic_form_for [@gate, @photo], :html => {:multipart => true} do |form| - form.inputs do = form.input :description, :as => :text = form.input :image, :as => :file = form.commit_button
do tego prosty krok do cucumbera:

When /^I attach file "([^\"]*)" in "([^\"]*)"$/ do |filename, field| full_file_path = Rails.root+filename content_type = File.new(full_file_path).content_type attach_file field, full_file_path, content_type end
i staram się wywołać ten scenariusz:

Scenario: Add new photo Given I am on the edit gate for street "Klonowa 5" in "Pruszków" When I follow "Manage photos" Then I should be on manage gate photos for street "Klonowa 5" in "Pruszków" And I should see "Manage photos for Klonowa 5, Pruszków" When I follow "Add new photo" And I fill in "Description" with "This is the first gate photo" And I attach file "spec/images/gate.jpg" in "photo_image" Then show me the page And I press "Create photo" Then I should see "Photo added." And I should see "This is the first gate photo" within ".description"
I teraz zaczyna się zabawa. W trakcie wypełniania foremki wywołuję wyżej wymieniony krok i otrzymuję komunikat o braku załączonego pliku.

And I press "Create photo" # features/step_definitions/web_steps.rb:22 Then I should see "Photo added." # features/step_definitions/web_steps.rb:142 expected the following element's content to include "Photo added.": Untitled Description*This is the first gate photo Image*must be set.
To w środowisku testowym, natomiast na developement wszystko jest ok. Plik się załącza, mam dostęp do wszystkich zdefiniowanych rozmiarów obrazów. Zrobiłem zatem mały test printując params w kontrolerze i w cucumberze otrzymuje:

{"description"=>"This is the first gate photo", "image"=>"/home/yanekk/projects/bramy/spec/images/gate.jpg"}

a w development:

{"description"=>"", "image"=>#<File:/tmp/RackMultipart20100408-5080-1piooog-0>}

co wg mnie oznacza, że webrat omija multipart i wysyła plik jako string. Gdzie tkwi błąd :|, męczę się od południa :stuck_out_tongue: