码迷,mamicode.com
首页 > 其他好文 > 详细

Rails中的测试RSpec升级遇到的问题

时间:2014-08-29 20:00:28      阅读:370      评论:0      收藏:0      [点我收藏+]

标签:des   cPage   style   blog   color   io   ar   文件   div   

 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_into10     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `each11     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `process_options_into12     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:22:in `configure13     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:96:in `setup14     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run15     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run16     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke17     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 `load19     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 `eval21     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 `configure25     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 `require27     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 `each29     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_into31     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `each32     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `process_options_into33     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:22:in `configure34     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:96:in `setup35     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run36     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run37     from /.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke38     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 `load40     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 `eval42     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中,问题解决。

其他小问题一大堆。。。头疼,下班。

Rails中的测试RSpec升级遇到的问题

标签:des   cPage   style   blog   color   io   ar   文件   div   

原文地址:http://www.cnblogs.com/woojuno/p/3945587.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!