我正在使用Cucumber和Capybara创建一些自动化测试。我想添加Touch Action gem(https://github.com/Ricardonacif/touch_action)。我添加了gem,然后在我的env文件中需要它,但我收到以下错误。我真的很困惑,我是否应该创建一个单独的帮助文件,但我尝试了这些行,但仍然得到相同的错误。有人可以就如何解决这个问题提出任何建议吗?
uninitialized constant RSpec (NameError)
/Users/em/.rvm/gems/ruby-2.1.1/gems/touch_action-1.3.0/lib/touch_action/capybara_rspec_helper.rb:17:in `<top (required)>'
/Users/em/.rvm/gems/ruby-2.1.1/gems/touch_action-1.3.0/lib/touch_action.rb:12:in `require'
/Users/em/.rvm/gems/ruby-2.1.1/gems/touch_action-1.3.0/lib/touch_action.rb:12:in `<top (required)>'
/Users/em/reallyenglish/learning_specs/learning-platform-specs/features/support/env.rb:3:in `require'
/Users/em/reallyenglish/learning_specs/learning-platform-specs/features/support/env.rb:3:in `<top (required)>'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/rb_support/rb_language.rb:94:in `load'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/rb_support/rb_language.rb:94:in `load_code_file'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:237:in `load_file'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:97:in `block in load_files!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:96:in `each'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:96:in `load_files!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:242:in `load_step_definitions'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:65:in `run!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/cli/main.rb:38:in `execute!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/bin/cucumber:9:in `<top (required)>'
/Users/em/.rvm/gems/ruby-2.1.1/bin/cucumber:23:in `load'
/Users/em/.rvm/gems/ruby-2.1.1/bin/cucumber:23:in `<main>'
/Users/em/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/em/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
的Gemfile
source "https://rubygems.org"
gem 'rake'
gem 'touch_action'
group(:test) do
gem 'cucumber'
gem 'capybara'
gem 'rspec'
gem 'selenium-webdriver'
end
env.rb
require 'capybara'
require 'capybara/cucumber'
require 'touch_action'
Capybara.configure do |config|
config.default_selector = :css
config.default_driver = :selenium
config.app_host = 'http://testem.co.uk
# Capybara.ignore_hidden_elements = false --video testing
config.include Capybara::DSL
end
After do
page.execute_script("window.localStorage.clear()")
end
答案 0 :(得分:1)
在我们的聊天讨论之后,touch-action
似乎需要明确要求rspec
。您的env.rb
文件应如下所示:
require 'rspec'
require 'capybara'
require 'capybara/cucumber'
require 'touch_action'