`alias_method':未定义的方法`to_json'对于`Object'类(NameError)

时间:2015-01-23 15:32:05

标签: ruby-on-rails unit-testing testing rspec

我想通过Rspec运行我的测试,但收到错误full trace here

其中一个是' alias_method': undefined method to_json'对于`Object'类(NameError)'我甚至不知道它来自哪里

require 'rubygems'
require 'spork'

Spork.prefork do
  ENV['RAILS_ENV'] ||= 'test'

  require File.expand_path('../../config/environment', __FILE__)  
  require 'capybara/rspec'
  require 'rspec/rails'
  require 'database_cleaner'
  require 'factory_girl'
  Dir[Rails.root + 'spec/support/**/*.rb'].map &method(:require)
  RSpec.configure do |config|
    config.include Capybara::DSL
    config.include FactoryGirl::Syntax::Methods   
    config.fixture_path = "#{::Rails.root}/spec/fixtures"
    config.mock_with :rspec
    config.order = :random
    config.use_transactional_fixtures = false
    config.use_instantiated_fixtures = true
    config.global_fixtures = :all
    config.infer_spec_type_from_file_location!
    config.raise_errors_for_deprecations!
    config.output_stream = 'rspec.xml'
    config.formatter = RspecJunitFormatter
    config.before do
      DatabaseCleaner.start
      ActionMailer::Base.deliveries.clear    
    end    
    config.after do
      DatabaseCleaner.clean
    end    
  end
end

宝石文件块

group :development, :test do
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'capybara'
  gem 'database_cleaner'
  gem 'factory_girl_rails', '~> 4.0'
  gem 'faker', git: 'https://github.com/stympy/faker.git'
  gem 'pry'
  gem 'rspec-rails', '~>3.0.0'
  gem 'selenium-webdriver'
  gem 'spork', :github => 'sporkrb/spork'
  gem 'spork-rails', :github => 'sporkrb/spork-rails'
  gem 'rspec_junit_formatter', :git => 'https://github.com/sj26/rspec_junit_formatter.git'
  gem 'rspec-core'
  gem 'rubocop', require: false
end

有任何建议如何解决?

Ruby 2.2.0

Rails 4.1.9

0 个答案:

没有答案