dem*_*mas 6 ruby sinatra cucumber 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
Run Code Online (Sandbox Code Playgroud)
功能/ 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
Run Code Online (Sandbox Code Playgroud)
测试一下:
cucumber features\one.feature
Run Code Online (Sandbox Code Playgroud)
结果:
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
Run Code Online (Sandbox Code Playgroud)
好吧,我创建了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
Run Code Online (Sandbox Code Playgroud)
测试一下:
cucumber features\one.feature
Run Code Online (Sandbox Code Playgroud)
结果:
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)
Run Code Online (Sandbox Code Playgroud)
为什么以及如何解决它?
更新: 如果我像这样重写我的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
Run Code Online (Sandbox Code Playgroud)
我认为 onlyCapybara.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
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,RVSWorld 类只有包含必要模块的语句。
| 归档时间: |
|
| 查看次数: |
3802 次 |
| 最近记录: |