Created
March 9, 2009 14:30
-
-
Save mislav/76330 to your computer and use it in GitHub Desktop.
Cucumber steps that integrate with Rails named routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^I go to(?: the)? (.*?)(?: page)?$/ do |name| | |
visit get_named_route(name) | |
end | |
Then /^I should be on(?: the)? (.*?)(?: page)?$/ do |name| | |
path.should == get_named_route(name) | |
end | |
## features/support/env.rb | |
ActionController::Integration::Session.class_eval do | |
def get_named_route(name) | |
case name | |
when 'my profile' | |
"/users/#{request.session[:user]}" | |
else | |
send(name.gsub(' ', '_') + '_path') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Rails 4+ then this also works, just change ActionController to ActionDispatch: