How should I do step like:
Given I should have Post with title "Hi" and text "Hello there"
And I should be on th开发者_如何学Ce show page for Post with ... some data
Then I click edit button
And I should be on edit page #of the some earlier created object
First, can I somehow save an Entity that was created in previous steps, instead of repeating Title and text (however, I can't know it definitely in some cases)? And perhaps there is no need to do it, enough to write smth like "I see text "title""? I saw that some developers doesn't test through bdd staff like routing (in my case), validation and whatever. What can you advise to me?
And if there is a need to do this routing test how can i parse that string, cause it's a typical crud, perhaps it has done many times, but i can't find it.
Your question is quite difficult to follow, but to answer it in part: You can share state between steps using instance variables, e.g.
Given /^a post$/
@post = Post.create!(:title => '...')
end
When /^I edit that post$/
visit post_edit_path(@post)
end
精彩评论