如何在 RSpec 和 Cucumber 中定义路径

发布于 2024-12-27 03:48:56 字数 455 浏览 1 评论 0原文

我正在阅读 Bigg 和 Katz 的《Rails 3 in Action》,这是我第一次阅读 RSpec、Cucumber 和 Capybara。

RSpec 团队大胆地“取消了辅助轮”,因此我只能遵循书中的概念,因为 RSpect 没有这样做。不再提供任何入门步骤,例如 paths.rbweb_steps.rb

我的问题是如何创建一条路径,就像在将水豚放在所需页面上的规范中一样。

在书中,它告诉将以下内容放入 paths.rb (由 RSpec 提供)

when /the project page for "([^\"]*)"/
   project_path(Project.find_by_name!($1))

I'm reading Rails 3 in Action by Bigg and Katz and its my first time with RSpec, Cucumber and Capybara.

The RSpec team boldly "took the training wheels off" So I'm stuck following along concepts in the book since RSpect doesn't provide any starter steps like paths.rb or web_steps.rb anymore.

My Question is how do I make a path, as in a spec that puts capybara on a desired page.

In the book, its told to put the following in paths.rb (provided by RSpec)

when /the project page for "([^\"]*)"/
   project_path(Project.find_by_name!($1))

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

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

发布评论

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

评论(1

泡沫很甜 2025-01-03 03:48:56

您引用的文章中,Aslak 指出他发布了 < a href="https://github.com/cucumber/cucumber-rails-training-wheels/" rel="nofollow">cucumber_rails_training_wheels 为处于您的情况的人们解决这个问题。我建议您在使用 Rails 3 in Action 时使用该库,或者使用仍支持它的旧版 Cucumber。

另外,仅供参考,RSpec 和 Cucumber 已经有两年多时间不再是同一个项目了。 web_steps.rb与Cucumber相关,与RSpec无关。

In the article you cite, Aslak points out that he released cucumber_rails_training_wheels to solve exactly this problem for people in precisely your situation. I'd recommend you use that library as you go through Rails 3 in Action, or use an older version of Cucumber that still supports it.

Also, just an FYI, RSpec and Cucumber haven't been the same project for over two years at this point. web_steps.rb is related to Cucumber, and has nothing to do with RSpec.

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