[rspec-users] Attachment-fu + Story Runner

Joe Van Dyk joe at pinkpucker.net
Fri Apr 4 19:33:58 EDT 2008


On Fri, Apr 4, 2008 at 4:10 PM, Joe Van Dyk <joe at pinkpucker.net> wrote:
> On Fri, Mar 21, 2008 at 5:46 AM, David Chelimsky <dchelimsky at gmail.com> wrote:
>  >
>  > On Fri, Mar 21, 2008 at 1:35 AM, Joe Van Dyk <joe at pinkpucker.net> wrote:
>  >  > On Thu, Mar 20, 2008 at 3:34 AM, Rick DeNatale <rick.denatale at gmail.com> wrote:
>  >  >  > On 3/20/08, Joe Van Dyk <joe at pinkpucker.net> wrote:
>  >  >  >  > What was the resolution on this?  How do you people test uploads with
>  >  >  >  >  rspec stories?
>  >  >  >
>  >  >  >  I submitted a Rails patch to address the underlying problem
>  >  >  >  http://dev.rubyonrails.org/ticket/11091
>  >  >  >
>  >  >  >  It got in as changeset 8978 and should be in edge rails.
>  >  >
>  >  >  Would it be worth it to monkeypatch that patch into rspec?
>  >
>  >  Why would we do that? It's already in edge rails.
>
>  Because I can't upgrade to edge rails.  And I want to be able to test
>  file uploads.
>
>  I've applied the 8978 changeset to my stable rails -- but I'm still
>  unsure of how to test file uploads in the context of a rspec story.
>  Normally, I'd use fixture_file_upload, but that method doesn't seem to
>  be available in rspec.  Do I need to do anything special?
>
>  Is anyone testing file uploads with rspec stories?

Think I got it working, here's an example step:

  When("$username uploads a picathon image") do |username|
    params = { :media =>
ActionController::TestUploadedFile.new(RAILS_ROOT +
'/test/fixtures/files/image.jpg') }
    @sessions[username].post user_uploads_path(@users[username]), params
    @sessions[username].visits user_uploads_path(@users[username])
  end


More information about the rspec-users mailing list