我的环境是这样的:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x64-mingw32]
- INSTALLATION DIRECTORY: D:/ruby-2.0.0/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: D:/ruby-2.0.0/bin/ruby.exe
- EXECUTABLE DIRECTORY: D:/ruby-2.0.0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
*** LOCAL GEMS ***
bigdecimal (1.2.0)
builder (3.2.2)
cucumber (1.3.18)
diff-lcs (1.2.5)
gherkin (2.12.2)
io-console (0.4.2)
json (1.8.1, 1.7.7)
minitest (4.3.2)
multi_json (1.10.1)
multi_test (0.1.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rspec (3.1.0)
rspec-core (3.1.7)
rspec-expectations (3.1.2)
rspec-mocks (3.1.3)
rspec-support (3.1.2)
test-unit (2.0.0.0)
问题一:
E:\practice\cucumberdemo>cucumber test.feature
WARNING: cannot load such file -- 2.0/gherkin_lexer_en
Couldn't load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/bin/../lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/builder-3.2.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.5/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_json-1.10.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/gherkin-2.12.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_test-0.1.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/json-1.8.1/lib
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/site_ruby
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/vendor_ruby
D:/ruby-2.0.0/lib/ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/2.0.0/x64-mingw32. Reverting to Ruby lexer.
WARNING: cannot load such file -- 2.0/gherkin_lexer_en
Couldn't load 2.0/gherkin_lexer_en
The $LOAD_PATH was:
lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/bin/../lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/builder-3.2.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/diff-lcs-1.2.5/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_json-1.10.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/gherkin-2.12.2/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/multi_test-0.1.1/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/cucumber-1.3.18/lib
D:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/json-1.8.1/lib
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/site_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/site_ruby
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/vendor_ruby/2.0.0/x64-msvcrt
D:/ruby-2.0.0/lib/ruby/vendor_ruby
D:/ruby-2.0.0/lib/ruby/2.0.0
D:/ruby-2.0.0/lib/ruby/2.0.0/x64-mingw32. Reverting to Ruby lexer.
这种错误,查询了一下google group邮件组的issues,发现是cucumber的一个bug,在Windows 64位系统上会出现,目前消除这种问题的方式是:找到../gems/gherkin-*.*.*/lib/gherkin/c_lexer.rb文件的第七行,修改 prefix = '',避免提示这种错误。
问题二:
按照正常的编写feature文件和step definition,却一直提示步骤未定义。
我之前使用的命令是到当前目录下执行cucumber test.feature,发现不行。改用cucumber cucumberdemo/test.feature -r cucumberdemo 才能执行。这个问题暂时先记着,回来找到原因我再补充。
问题三:
总是提示:cannot load such file -- spec/expectations (LoadError)
这个是因为rspec-expectations在3.0版本以上修改了运行的逻辑,需要在env.rb中把require 'spec/expectations' 修改成 require 'rspec' 才行。