1 bundle exec rspec spec/ 2 /home/wuxj/Prac/rrprac/sample_app/spec/spec_helper.rb:20:in `block in <top (required)>': uninitialized constant Capybara (NameError) 3 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core.rb:79:in `configure' 4 from /sample_app/spec/spec_helper.rb:17:in `<top (required)>' 5 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `require' 6 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `block in requires=' 7 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `each' 8 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `requires=' 9 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into' 10 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `each' 11 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `process_options_into' 12 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:22:in `configure' 13 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:96:in `setup' 14 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run' 15 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run' 16 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke' 17 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>' 18 from /.rvm/gems/ruby-2.1.2/bin/rspec:23:in `load' 19 from /.rvm/gems/ruby-2.1.2/bin/rspec:23:in `<main>' 20 from /.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval' 21 from /.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>' 22 wuxj@P-D5-wuxj:~/Prac/rrprac/sample_app$ bundle exec rspec spec/ 23 /Prac/rrprac/sample_app/spec/spec_helper.rb:20:in `block in <top (required)>': uninitialized constant Capybara (NameError) 24 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core.rb:79:in `configure' 25 from /Prac/rrprac/sample_app/spec/spec_helper.rb:17:in `<top (required)>' 26 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `require' 27 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `block in requires=' 28 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `each' 29 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `requires=' 30 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into' 31 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `each' 32 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `process_options_into' 33 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:22:in `configure' 34 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:96:in `setup' 35 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run' 36 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run' 37 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke' 38 from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>' 39 from /.rvm/gems/ruby-2.1.2/bin/rspec:23:in `load' 40 from /.rvm/gems/ruby-2.1.2/bin/rspec:23:in `<main>' 41 from /.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval' 42 from /.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
查来查去都是什么乱说一通,改这地方改那地方,我了个去的,太不靠谱了,后来综合各个老外的说法,思考了下然后试着去改,老天真照顾我,好用了。哈哈~~~
首先查到的是Capybara不在rspec中,所以要添加进去,但是添加的是spec_helper.rb文件中
config.include Capybara::DSL
结果:依然没解决。
其次,因为版本升级,现在rspec已经分为两块,一个spec_helper.rb和一个rails_helper.rb
从生成的测试文件看
1 require 'rails_helper' 2 3 RSpec.describe "StaticPages", :type => :request do 4 # describe "GET /static_pages" do 5 # it "works! (now write some real specs)" do 6 # get static_pages_index_path 7 # expect(response.status).to be(200) 8 # end 9 # end 10 11 describe "Home page" do 12 it "should have the content 'Sample App'" do 13 visit '/static_pages/home' 14 expect(page).to have_content('Sample App') 15 end 16 end 17 end
引用的是rails_helper,所以我试着把这个东西移到rails_helper中,问题解决。
其他小问题一大堆。。。头疼,下班。