我创建了一个rails应用程序,然后从另一个应用程序导入Gemfile,包括spec文件。当我运行rspec时,我得到以下错误。我做错了什么?
我的Gemfile如下:
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'therubyracer', platforms: :ruby
gem 'capybara', '~> 2.4.4'
gem 'poltergeist', '~> 1.6.0'
gem 'phantomjs', '~> 1.9.8.0'
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'httparty'
我的spec_helper.rb如下:
require 'rspec'
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
RSpec.configure do |config|
config.include Capybara::DSL
end
我在下面看到的错误:
/Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:2157:in `method_missing': undefined method `this' for #<Gem::Specification:0x3fed45440788 nokogiri-1.6.7.2> (NoMethodError)
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1056:in `find_active_stub_by_path'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:63:in `require'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.7.2/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.7.2/lib/nokogiri.rb:25:in `<top (required)>'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:119:in `require'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:119:in `require'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/capybara-2.6.0/lib/capybara.rb:2:in `<top (required)>'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in require'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /Users/subratrout/rails_projects/recipefindern/spec/spec_helper.rb:2:in `<top (required)>'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/subratrout/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires='
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires='
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/bin/rspec:23:in `load'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/bin/rspec:23:in `<main>'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/subratrout/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
答案 0 :(得分:1)
我有完全相同的错误。 这很奇怪,因为在其他类似项目中,rspec工作正常。 我用rvm安装了旧版本的ruby(2.2.3),安装了gems并且它工作正常。
rvm install ruby-2.2.3
rvm ruby-2.2.3
gem install rspec
gem install rspec-its
gem install capybara
gem install poltergeist
然后rspec开始工作。
如果有帮助,请写下来:)
答案 1 :(得分:0)
我所要做的就是删除Gemfile.lock文件,然后进行捆绑安装。不知何故,新的Ruby版本与Nokogiri版本1.6.7.2发生冲突。