On Fri, Apr 10, 2009 at 11:49 AM, Lenny Marks <le...@aps.org> wrote: > > One place I've actually been interested in testing URLs was to verify that > the app actually redirected after a form submission.
I can agree with this, and I had a similar need just the other day. I had an action that redirected to different places depending on whether a certain box was checked. But I didn't spec it by checking the literal text of URL itself. Instead I worked with the paths functionality that was already in Cucumber's support directory, and made it a bit more flexible. Here was my situation: Scenario: Has an Enclosure Given I am a contributor When I go to the create episode page And I fill in [...blah blah, submitting the form...] Then I should have an episode titled "Any title" And I should be on the create enclosure page for that episode ...I wanted that "I should be on (foo) for that (bar)" to be general, so in my application_steps.rb: Then /^I should be on (.*page) for that (.*)$/ do |page, element| current_url.should == path_to(page, instance_variable_get("@#{element}")) end ...And finally, I rewrote the path_to method in paths.rb a bit: def path_to(page_name, parent_object = nil) case page_name [ . . . ] when /the create enclosure page/i new_episode_enclosure_url(parent_object) This all worked, and it worked well. Though of course, going through the work of specing and building a separate enclosure model made me decide that it would really work better as a simple Paperclip attribute inside episode, so I threw all that away... But c'est la vie. >8-> -- Have Fun, Steve Eley (sfe...@gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users