[cucumber] Assertions about current location in Then steps

Hello,

is there currently a way to make assertions about the current location
in Then steps? Here’s an example of what I would like to do:

Scenario: Creating a post
Given I am on the the posts page
When I fill in …
And …
Then I should be on the homepage

I have seen many cases where the last assertion is replaced by a ‘Then I
should see “”’. But I can’t help
but feel that depending on the specific wording is way to brittle. And
since I could also check the current location by looking at the address
bar (if I ran the test manually) I guess it would not be a violation if
cucumber did (as opposed to checking for records in the database etc).

Thoughts?

Tim

On Sun, May 3, 2009 at 11:28 AM, Tim F. [email protected]
wrote:

is there currently a way to make assertions about the current location
in Then steps? Here’s an example of what I would like to do:

Scenario: Creating a post
Given I am on the the posts page
When I fill in …
And …
Then I should be on the homepage

I have granted your wish. :slight_smile:

Seriously, webrat_steps.rb already has this, if I understand you
correctly:

Then /^I should be on (.+)$/ do |page_name|
request.path.should == path_to(page_name)
end

///ark

I have this in my webrat_steps.rb already:

Then /^I should be on (.+)$/ do |page_name|
URI.parse(current_url).path.should == path_to(page_name)
end

(I think it came that way)

– Matt

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs