我正在努力为我的网络项目设置watir-rspec框架进行ui测试。 (https://github.com/watir/watir-rspec)
以下是我采取的步骤:
以下是我遇到的错误:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-rspec-1.1.0/lib/watir/rspec/helper.rb:4:in `<module:Helper>': uninitialized constant Watir::RSpec::Helper::Forwardable (NameError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-rspec-1.1.0/lib/watir/rspec/helper.rb:3:in `<class:RSpec>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-rspec-1.1.0/lib/watir/rspec/helper.rb:2:in `<module:Watir>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-rspec-1.1.0/lib/watir/rspec/helper.rb:1:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-rspec-1.1.0/lib/watir/rspec.rb:47:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
from C:/wamp/www/smart/tests/ui-test/spec/spec_helper.rb:3:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from C:/wamp/www/smart/tests/ui-test/spec/example_spec.rb:1:in `<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'
我错过了哪些步骤?我甚至试图正确地运行测试吗?
显然我对这件事情有点新鲜 - 任何帮助都会受到赞赏。
答案 0 :(得分:1)
您看到的异常似乎是watir / rspec执行extend Forwardable
,并假设已经需要Forwardable。添加require 'forwardable'
将解决此问题。
一旦修复了,我得到了未初始化的常量Watir :: Browser异常。似乎watir / rspec不会自动为您提供watir。您需要手动执行此操作,因此添加require 'watir'
行。
总之,按照您所做的步骤,我发现我必须对spec_helper.rb进行2次更改。在文件的顶部(即require watir/rspec
行之前)添加以下行:
require 'forwardable'
require 'watir'