开发者

How to write cucumber test?

I want to write test for edit post I write something like:

Given I'm on "/post/1/edit" page

but in this time I haven't record with ID = 1, even if I created it in previous test开发者_JS百科

How to solve it?


Because it's a test database, you won't know what the id is exactly. I think you're better off to follow the edit link from the index after the post is created.


You could say:

Given a post exists
When I edit that post

And the steps defs could be:

Given /^a post exists$/ do
  @post = Post.create!(:title => "...")
end

When /^I edit that post$/ do
  visit edit_post_path(@post)
end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜