开发者

Cucumber CRUD Edit and Preview pages

开发者 https://www.devze.com 2023-04-05 12:02 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消