Created
November 18, 2009 08:14
-
-
Save cbeier/237651 to your computer and use it in GitHub Desktop.
general cucumber paths (restful)
This file contains 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
# Request in the feature -> ... the user show "foo" page by "login" | |
# -> features/support/paths.rb | |
when /^the (.*) (edit|show)( "([^\"]*)")? page by "([^\"]*)"$/i | |
case $2 | |
when "edit","show" | |
klass = $1.singularize.capitalize.constantize | |
obj = klass.send("find_by_#{$5.singularize}", $4) if $4 && $5 | |
raise "could not find #{$3} #{$1}" unless obj | |
return self.send("edit_#{$1.downcase.singularize}_path",obj) if $2=="edit" | |
return self.send("#{$1.singularize}_path",obj) if $2=="show" | |
end | |
when /^the (.*) (overview|new)( "([^\"]*)")? page$/i | |
case $2 | |
when "new" | |
self.send("new_#{$1.downcase.singularize}_path") | |
when "overview" | |
self.send("#{$1.downcase.pluralize}_path") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment