RailsのテストRSpecのアップグレードで発生した問題
18303 ワード
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は2つのブロックに分かれ、1つの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では、問題が解決します.
他の小さな問題が山積みになっています...頭が痛くて、退勤します.