2012-03-31 65 views
6

我有Sinatra应用程序,需要测试我的应用程序。堆栈层面太深(SystemStackError)

功能/支持/ env.rb:

require_relative "../../application" 

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

World do 
    Capybara.app = Application 

    include Capybara::DSL 
    include RSpec::Matchers 
end 

功能/ 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 

好了,我已经创建功能/ 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这样dissapeared问题:

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 
+0

你可以发布你的Gemfile.lock还是更多,所以你使用的是什么版本的黄瓜,水豚和rspec – Dan 2012-03-31 11:03:19

+0

我已经发布我的Gemfile.lock在这里:http://pastebin.com/8Ni5MSdj – demas 2012-03-31 11:13:09

+0

@Jacob,Rspec是对于断言而水豚只是与网络驱动程序交谈。据说,你一定需要Rspec和水豚(也可能是Selenium) – 2013-06-12 20:57:52

回答

0

我相信只有Capybara.app = Application不应声明中World的展现在你的榜样。

因此,这里是我的工作env.rb

ENV['RACK_ENV'] = 'test' 
require File.join(File.dirname(__FILE__), '..', '..', 'rvs.rb') 

require 'capybara' 
require 'capybara/cucumber' 
require 'rspec' 
require 'r18n-core' 

Capybara.app = RVS 

class RVSWorld 
    include R18n::Helpers 
    include Capybara::DSL 
    include RSpec::Expectations 
    include RSpec::Matchers 
end 

World do 
    RVSWorld.new 
end 

正如你可以看到RVSWorld类只有声明,其中包括必要的模块。

1

我居然也得到了相同的外观相似error..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' ......这会首先装载。

现在没有更多的即时通讯面临的错误。

相关问题