Ruby 堆栈级别太深(SystemStackError)
我有Sinatra应用程序,需要测试我的应用程序 功能/支持/env.rb:Ruby 堆栈级别太深(SystemStackError),ruby,cucumber,sinatra,capybara,Ruby,Cucumber,Sinatra,Capybara,我有Sinatra应用程序,需要测试我的应用程序 功能/支持/env.rb: require_relative "../../application" require "capybara" require "capybara/cucumber" require "rspec" World do Capybara.app = Application include Capybara::DSL include RSpec::Matchers end Feature: Test h
require_relative "../../application"
require "capybara"
require "capybara/cucumber"
require "rspec"
World do
Capybara.app = Application
include Capybara::DSL
include RSpec::Matchers
end
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
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
功能/一个。功能:
require_relative "../../application"
require "capybara"
require "capybara/cucumber"
require "rspec"
World do
Capybara.app = Application
include Capybara::DSL
include RSpec::Matchers
end
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
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
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
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)
嗯,我已经创建了功能/步骤定义/议程步骤。rb:
require_relative "../../application"
require "capybara"
require "capybara/cucumber"
require "rspec"
World do
Capybara.app = Application
include Capybara::DSL
include RSpec::Matchers
end
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
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
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
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
我认为只有
Capybara.app=Application
不应该在World
中声明,如您的示例所示
下面是我的工作环境.rb:
正如您所看到的,RVSWORD类只有包含必要模块的语句。我得到了相同的“外观相似”错误
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'
,它们首先被加载
现在我不再面对这个错误了。你能发布你的Gemfile.lock或者更多吗?那么你使用的cucumber、capybara和rspec的版本是什么呢?我已经在这里发布了我的Gemfile.lock:@Jacob,rspec用于断言,而capybara只是与web驱动程序对话。说到这里,你肯定需要Rspec和水豚草(可能还需要硒)