1. 程式人生 > >安裝cucumber遇到的幾個問題

安裝cucumber遇到的幾個問題

我的環境是這樣的:

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' 才行。