Cucumber / JRuby - 未初始化的常量语法:: Ruby :: Set Error创建格式化程序:html(NameError)

时间:2014-03-31 08:03:51

标签: cucumber jruby formatter uninitialized-constant

我正在使用JRUBY / Cucumber / Watir框架,我有一个特定的功能文件夹,每次尝试使用内置的HTML格式化程序时都会抛出此错误:

    uninitialized constant Syntax::Ruby::Set
    Error creating formatter: html (NameError)
    org/jruby/RubyModule.java:2690:in `const_missing'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/syntax-1.2.0/lib/syntax         /lang/ruby.rb:11:in `Ruby'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/syntax-1.2.0/lib/syntax  /lang/ruby.rb:8:in `Syntax'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/syntax-1.2.0/lib/syntax/lang/ruby.rb:3:in `(root)'
    org/jruby/RubyKernel.java:1083:in `require'
    /Users/Casey.Guerrero/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/Casey.Guerrero/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:53:in `require'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/syntax-1.2.0/lib/syntax.rb:1:in `(root)'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/syntax-1.2.0/lib/syntax.rb:24:in `load'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/syntax-1.2.0/lib/syntax/convertors/abstract.rb:16:in `for_syntax'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/formatter/html.rb:580:in `SnippetExtractor'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/formatter/html.rb:578:in `Html'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/formatter/html.rb:8:in `Formatter'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/formatter/html.rb:7:in `Cucumber'
org/jruby/RubyKernel.java:1083:in `require'
    /Users/Casey.Guerrero/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/Casey.Guerrero/.rvm/rubies/jruby-1.7.10/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:53:in `require'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/formatter/html.rb:6:in `(root)'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/constantize.rb:1:in `(root)'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/constantize.rb:17:in `constantize'
    org/jruby/RubyArray.java:2409:in `map'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/cli/configuration.rb:81:in `formatter_class'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/cli/configuration.rb:182:in `formatters'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/cli/configuration.rb:178:in `formatters'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/cli/configuration.rb:76:in `build_tree_walker'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/runtime.rb:46:in `run!'
    org/jruby/RubyKernel.java:1099:in `load'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/gems/cucumber-1.3.14/bin/../lib/cucumber/cli/main.rb:47:in `execute!'
    org/jruby/RubyKernel.java:1119:in `eval'
    /Users/Casey.Guerrero/.rvm/gems/jruby-1.7.10/bin/jruby_executable_hooks:15:in `(root)'

使用cucumber-1.3.14jruby-1.7.10,虽然jruby-1.7.4出错。支持目录中不包含任何格式化程序,也不会在env.rb.中的任何位置引用格式化程序。不使用rake或运行单个功能的任何内容。奇怪的是,其他功能文件夹可以使用与失败的命令参数相同的命令参数输出html报告。例如:

cucumber features/AddText.feature -f html -o report.html -f pretty 

cucumber features/AddText.feature --format html --out report.html --format pretty

任何见解都会有所帮助。

更新:

出于某种原因卸载然后'syntax'gem允许运行功能并生成html报告。我的印象是'语法'是'黄瓜'依赖...

3 个答案:

答案 0 :(得分:3)

当Cucumber发生测试失败时,会将以下行写入控制台:

# gem install syntax to get syntax highlighting

不幸的是,这导致人们安装语法gem,这是导致错误的原因。

执行“gem uninstall syntax”或“sudo gem uninstall syntax”以避免此错误。

答案 1 :(得分:0)

运行“gem uninstall syntax”这将起作用

答案 2 :(得分:0)

我知道这有点旧帖,但想清楚一些事情。

黄瓜1.3.17和1.3.18依赖于语法> = 1.0.0

并且在当前情况下,问题是语法1.2.0而不是所有语法版本。

所以我们应该做的是

卸载语法1.2.0并安装语法1.0.0

sudo gem install syntax -v 1.0.0