2012-01-06 6 views
7

私はアプリで使っています。これはruby 1.8.6で動作する2.2.2のアプリです(アップグレードは今すぐオプション)。キュウリはうまかった、今私はカピバラを使用しようとしている。私はcapybara (1.1.1)の宝石をインストールし、require 'capybara/rails'を私のfeatures/support/env.rb fileに入れました。"require 'capybara/rails" "初期化されていない定数Rack :: Builder"を与えます

私はキュウリを実行すると、私はこのエラーを取得:4行目はRack::Builder.new行でエラーを作成している、だから、

#/home/max/.rvm/gems/[email protected]/gems/capybara-1.1.1/lib/capybara/rails.rb 
require 'capybara' 
require 'capybara/dsl' 

Capybara.app = Rack::Builder.new do 
    map "/" do 
    if Rails.version.to_f >= 3.0 
     run Rails.application 
    else # Rails 2 
     use Rails::Rack::Static 
     run ActionController::Dispatcher.new 
    end 
    end 
end.to_app 

Capybara.asset_root = Rails.root.join('public') 
Capybara.save_and_open_page_path = Rails.root.join('tmp/capybara') 

Using the default profile... 
uninitialized constant Rack::Builder (NameError) 
/home/max/.rvm/gems/[email protected]/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in `load_missing_constant' 
/home/max/.rvm/gems/[email protected]/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in `const_missing' 
/home/max/.rvm/gems/[email protected]/gems/capybara-1.1.1/lib/capybara/rails.rb:4 
/home/max/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' 
/home/max/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' 
/home/max/.rvm/gems/[email protected]/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in `require' 
/home/max/work/charanga/elearn_container/elearn/features/support/env.rb:10 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/rb_support/rb_language.rb:143:in `load' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/runtime/support_code.rb:171:in `load_file' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/runtime/support_code.rb:83:in `load_files!' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/runtime/support_code.rb:82:in `each' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/runtime/support_code.rb:82:in `load_files!' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/runtime.rb:137:in `load_step_definitions' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/runtime.rb:39:in `run!' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/cli/main.rb:43:in `execute!' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/../lib/cucumber/cli/main.rb:20:in `execute' 
/home/max/.rvm/gems/[email protected]/gems/cucumber-1.1.1/bin/cucumber:14 
/home/max/.rvm/gems/[email protected]/bin/cucumber:19:in `load' 
/home/max/.rvm/gems/[email protected]/bin/cucumber:19 

はここerroringファイルです。しかし、なぜ?何か案は?私はすでにラックの宝石をインストールしています。

+0

spec/spec_helper.rbを追加するとすぐに 'capybara/rails'が必要です。エラーメッセージ '/vendor/rails/activesupport/lib/active_support/dependencies.rb:445: 'load_missing_constant ':初期化されていない定数Rack :: Builder(NameError)' – hebe

+0

1.8.7にアップグレードするオプションではない、または1.9/2.0にする?あなたの問題を解決するかもしれません。 – fotanus

答えて

1

最大

おかげで、あなたはキュウリレールの宝石を使用しましたか? features/support/env.rbrequire 'capybara/rails'require 'rack/builder'を追加

require 'capybara/cucumber' 
Capybara.app = MyRackApp 
+0

これはキュウリのテストランナーではないので、この回答は私を助けませんでした。 – satyajit

3

試してみてください。

は宝石を使用するか、your'reはレールを使用していない場合は、これらの行の両方を置くのいずれか、と言います。 2.3未満のRailsバージョンではRackを内部的に使用しないため、capybaraが想定しているようにRack :: Builderはロードされません。

0

gem install rack 

    require 'rack' # in features/support/env.rb before every require 

ラック::ビルダーは、ラックのライブラリで定義され、これを試してみてください。

+0

詳しいことはありますか? – Paul

+0

@Paul、Rack :: Builderはラックライブラリで定義されています。 –

関連する問題