ruby - 堆栈级别太深(SystemStackError)

标签 ruby cucumber sinatra capybara

我有 Sinatra 应用程序,需要测试我的应用程序。

features/support/env.rb:

require_relative "../../application"

require "capybara"
require "capybara/cucumber"
require "rspec"

World do
  Capybara.app = Application

  include Capybara::DSL
  include RSpec::Matchers
end

features/one.feature:

Feature: Test homepage
  In order to make sure people can open my site
  I want to check it opened

  Scenario: Opening first page
    Given I have opened homepage    
    Then I should see site header

测试它:

cucumber features\one.feature

结果:

Feature: Test homepage
  In order to make sure people can open my site
  I want to check it opened

  Scenario: Opening first page    # features\one.feature:5
    Given I have opened homepage  # features\one.feature:6
    Then I should see site header # features\one.feature:7

1 scenario (1 undefined)
2 steps (2 undefined)
0m0.006s

You can implement step definitions for undefined steps with these snippets:

Given /^I have opened homepage$/ do
  pending # express the regexp above with the code you wish you had
end

Then /^I should see site header$/ do
  pending # express the regexp above with the code you wish you had
end

好吧,我已经创建了 features/step_definitions/agenda_steps.rb:

Given /^I have opened homepage$/ do
  pending # express the regexp above with the code you wish you had
end

Then /^I should see site header$/ do
  pending # express the regexp above with the code you wish you had
end

测试它:

cucumber features\one.feature

结果:

Feature: Test homepage
  In order to make sure people can open my site
  I want to check it opened

  Scenario: Opening first page    # features\one.feature:5
    Given I have opened homepage  # features/step_definitions/agenda_steps.rb:1
C:/Ruby193/bin/cucumber:19: stack level too deep (SystemStackError)

为什么以及如何解决?

更新:如果我像这样重写我的 env.rb,问题就消失了:

require_relative "../../application"

require "capybara"
require "capybara/cucumber"
require "rspec"


Capybara.app = Application
#World do
#  Capybara.app = Application
# 
#  include Capybara::DSL
#  include RSpec::Matchers
#end

最佳答案

我得到了同样的相似错误..as

stack level too deep (SystemStackError)
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/cucumber-1.1.4/lib/cucumber/core_ext/instance_exec.rb:73..

我在 env.rb 的第一行 中添加了 require 'cucumber/rails'...首先加载。

现在我再也不会遇到那个错误了。

关于ruby - 堆栈级别太深(SystemStackError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9955008/

相关文章:

ruby - 如何使用 mina 执行 rake 任务?

ruby-on-rails - 蜻蜓和短网址

javascript - rails 4 : calling ruby extra class methods on user input with JavaScript/jQuery

Ruby - 使用扫描拆分多个字符串

ruby-on-rails - Rails 测试中缺少记录

ruby-on-rails - 有条件地需要基于 Rails 或 Sinatra 框架的 Gemfile 中的 gem?

sql - 如何将 (sql) 数据库添加到我的 sintra 应用程序?

ruby-on-rails - Ruby on Rails : Why does the user's encrypted password get changed in the DB when I use the "toggle" method on the admin attribute?

jenkins - 显示所有结果的最佳 Jenkins 仪表板插件是什么?

java - 尝试加载不同的属性以进行 Spring Boot 应用程序的 Cucumber 集成测试?