Created
December 22, 2011 19:15
-
-
Save chrisbraddock/1511475 to your computer and use it in GitHub Desktop.
Write Better Cukes
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
# question regarding http://blog.steveklabnik.com/2011/12/20/write-better-cukes-with-the-rel-attribute.html | |
# | |
When /^I choose to edit the article "([^"]*)"$/ do |article_name| | |
article = Article.find_by_name(article_name) | |
find("//a[@href='#{edit_article_path article}']").click | |
end |
In considering doing what you're doing I've been concerned (perhaps wrongly) that there might be another edit article link on a tested page (now or in the future) and the test doesn't account for that.
I guess I was more curious as to what you thought about the Cuke step using the same code that will (likely) be used to generate the on-page link (i.e. "edit_article_path article").
To that end and to remove the article_name bit from the equation I guess you could consider something like:
When /^I choose to edit the article$/ do
article = @article # assigned in earlier step
find("//a[@href='#{edit_article_path article}']").click
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This ties the editing concept to your titles. It also loses all of the natural language aspect...