如何在 RSpec 和 Cucumber 中定义路径
我正在阅读 Bigg 和 Katz 的《Rails 3 in Action》,这是我第一次阅读 RSpec、Cucumber 和 Capybara。
RSpec 团队大胆地“取消了辅助轮”,因此我只能遵循书中的概念,因为 RSpect 没有这样做。不再提供任何入门步骤,例如 paths.rb
或 web_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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您引用的文章中,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.