1

我最近拿起了 page-object gem,但是当包含这个 gem 时,我无法让我的测试(基于 Cucumber/Selenium)运行。

根据 gem list,我安装了 gem:

page-object (0.9.1)

我的 env.rb 文件包括:

require 'page-object'

但是,当我尝试运行测试时,我收到以下错误:

/Library/Ruby/Gems/1.8/gems/page-object-0.9.1/lib/page-object/widgets.rb:32:语法错误,意外'=',期待'|' ...dget_tag do |name, identifier={:index => 0}, &block| ^ /Library/Ruby/Gems/1.8/gems/page-object-0.9.1/lib/page-object/widgets.rb:32:语法错误,意外',',期待kEND ...ame,标识符= { :index => 0}, &block| ^ /Library/Ruby/Gems/1.8/gems/page-object-0.9.1/lib/page-object/widgets.rb:122:语法错误,意外的 kEND,期待 $end (SyntaxError) /Library/Ruby/Site /1.8/rubygems/core_ext/kernel_require.rb:51:ingem_original_require' /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:51:in要求' /Library/Ruby/Gems/1.8/gems/page-object-0.9.1/lib/page-object.rb:10 />图书馆/Ruby/站点/1.8/rubygems/core_ext/kernel_require.rb:116:ingem_original_require' />Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:116:in需要' /Users/garethbragg/dev/trade-finder/test/cucumber/features/support/env.rb:6 /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/ cucumber/rb_support/rb_language.rb:122:in load' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/rb_support/rb_language.rb:122:inload_code_file' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:180:in load_files load_file' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:83:in! ' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:82:in each' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:82:inload_files!/Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime.rb:183:in load_step_definitions' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime.rb:42:inrun!/Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/cli/main.rb:47:in execute!' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/cucumber:13 /usr/bin/cucumber:23:inload' /usr/bin/cucumber:23

如果我在我的任何课程中包含 PageObject,我会收到以下信息:

未初始化的常量 Home::PageObject (NameError) ./lib/Home.rb:4 /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:51:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:51:inrequire' /Users/garethbragg/dev/trade-finder /test/cucumber/features/support/env.rb:2 /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/rb_support/rb_language.rb:122:in load' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/rb_support/rb_language.rb:122:inload_code_file ' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:180:in load_file' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:83:inload_files!' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:82:in each' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime/support_code.rb:82:inload_files!/Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime.rb:183:in load_step_definitions' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/runtime.rb:42:inrun!/Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/../lib/cucumber/cli/main.rb:47:in execute!' /Library/Ruby/Gems/1.8/gems/cucumber-1.3.5/bin/cucumber:13 /usr/bin/cucumber:23:inload' /usr/bin/cucumber:23

任何建议将不胜感激。

4

2 回答 2

1

我相信错误是由于您使用 ruby​​ 1.8 造成的。你可以试试 1.9 或更高版本吗?

于 2013-08-10T12:19:50.783 回答
0

我今天早些时候遇到了同样的问题。我修复了它(正如 Cheezy 建议的那样),更新了我的 ruby​​ 版本。(1.9.3)。

还值得注意的是,我更新了 ruby​​gems,删除了我的 Gemfile.lock,并运行了另一个包安装。(我也将 rvm 用于我的 ruby​​ 版本)

于 2013-08-23T18:17:25.090 回答