Cucumber CRUD 编辑和预览页面

发布于 2024-12-05 04:39:42 字数 475 浏览 0 评论 0原文

我应该如何执行以下步骤:

 Given I should have Post with title "Hi" and text "Hello there"
 And I should be on the 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

首先,我可以以某种方式保存在前面的步骤中创建的实体,而不是重复标题和文本(但是,在某些情况下我无法确定它)?也许没有必要这样做,足以写出像“我看到文本“标题””这样的东西? 我发现一些开发人员不通过 bdd 人员进行测试,例如路由(在我的例子中)、验证等。你能给我什么建议?

如果需要进行此路由测试,我如何解析该字符串,因为它是典型的CRUD,也许它已经做了很多次,但我找不到它。

How should I do step like:

 Given I should have Post with title "Hi" and text "Hello there"
 And I should be on the 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜你已久 2024-12-12 04:39:42

您的问题很难理解,但要部分回答:您可以使用实例变量在步骤之间共享状态,例如

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

When /^I edit that post$/
  visit post_edit_path(@post)
end

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文