Ruby on Rails:paths.rb 的 Cucumber 自定义定义
我试图学习 BDD 开发方式,刚刚观看了 Cucumber 的 RailsCasts 课程。在那里,我看到了描述一些动作的方法,例如:
When I go to the list of articles
Then I should see "Pizza"
并且,据我了解,所有这些“我去”和“我应该看到”的结构都硬编码在某处。所以在 paths.rb 中我可以写:
def path_to(page_name)
case page_name
when /the list of articles/
articles_path
下次它会自动识别这条路径。和“我应该看看”具有相同的功能。
那么,问题是:有没有办法用另一种语言或自定义序列替换那些“我去”和“我应该看到”结构?例如:
When I constantly visiting the list of articles
Then I have to observe text "Pizza"
I trying to learn BDD way for development and just watched RailsCasts lesson for Cucumber. There i've seen approach to describe some actions like:
When I go to the list of articles
Then I should see "Pizza"
And, as i understand all those "I go to" and "I should see" constructions hardcoded somewhere. So in paths.rb i can write:
def path_to(page_name)
case page_name
when /the list of articles/
articles_path
And it'll recognize this path next time automaticaly. And "i should see" has same feature.
So, the question: is there ant way to replace those "I go to" and "I should see" constructions with another language or custom sequences? For example:
When I constantly visiting the list of articles
Then I have to observe text "Pizza"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,
Cucumber 使用 web_steps.rb 中的步骤来调用映射。它看起来像:
所以,我会编写以下步骤来重定向到标准 web_steps ...
希望这会有所帮助。
Sure,
Cucumber uses the steps in web_steps.rb to make the call to the mapping. It looks like:
So, I would write the following step that redirect to the standard web_steps ...
Hope this helps.