[rspec-users] attachment_fu and story runner, any updates

Rick DeNatale rick.denatale at gmail.com
Tue Feb 12 16:11:56 EST 2008

On 2/12/08, Ben Mabey <ben at benmabey.com> wrote:

> I'll check it out when I get a chance.  BTW, would you mind posting some
> example code of how you are using the story runner in testing a
> multi-part form?
require File.expand_path(File.dirname(__FILE__) + "/helper.rb")

Test::Unit::TestCase.fixture_path = RAILS_ROOT + '/spec/fixtures/'

def add_the_rebelz
  @image_filename = "therebelz.jpg"
  upload_data = fixture_file_upload(@image_filename, "image/jpg")
  post_via_redirect("/artists", {:artist => {:name => "The Rebelz"},
:image => {:uploaded_data => upload_data}})
  @artist = Artist.find_by_name("The Rebelz")

Story "Sign up an Artist", %{
  As an administrator
  I want to add the Artist to the system
  So that the Artist can be accessed
}, :type => RailsStory do
  Scenario "New Artist" do
    Given "The Artist is not in the system" do
      pm = Artist.find_by_name("The Rebelz")
      pm.destroy if pm
    When "I add the Artist" do
    Then "The Artist page should show the Artist's name" do
      response.should have_text(/The Rebelz/)
      And "The page should show the artist's  picture or logo" do
        response.should have_tag("span.artist_logo") do
          with_tag("img[src*=?]", @image_filename)

Rick DeNatale

My blog on Ruby

More information about the rspec-users mailing list