当我运行bundle exec cucumber时,在幕后完全发生了什么?

时间:2013-10-05 16:27:30

标签: cucumber capybara

当我尝试为我的网络应用程序运行黄瓜方案时,是否有任何文档或其他内容可以让我知道发生了什么。

  • 何时以及如何启动服务器?

我使用Capybara,webkit,无头宝石作为我的技术堆栈。

1 个答案:

答案 0 :(得分:1)

我建议您查看Capybara和Cucumber的代码(理想情况下是您正在使用的宝石版本)。我发现从Capybara启动服务器的位置向后工作更容易,而不是从调用Cucumber时向前工作。

Capybara::Server是负责启动服务器的类。

Capybara::Session creates an instance of Capybara::Server

将驱动程序设置为:Capybara#current_session creates a new instance of Capybara::Session时将使用webkit。

page, a method in Capybara's DSL, just returns current_session

所有DSL方法,例如visit get sent to the current_session through page。在DSL文件的顶部,有一条评论显示"When using capybara/dsl, the Session is initialized automatically for you."

通过使用cucumber-rails或by manually requiring capybara/cucumber,您可以获得capybara DSL methods included in Cucumber's World

我有一段时间没有使用黄瓜,但我想我记得他们从黄瓜中删除了任何预先填充的步骤定义,所以实际上没有任何我想到的地方可以链接到Cucumber的代码,但这是第一次步骤定义调用Capybara DSL方法,就像服务器启动时一样。

相关问题