- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我运行 rspec 进行测试时,我得到了这个错误:
无法加载这样的文件 -- mocha/object (LoadError)问题在于以下行:config.mock_with :mocha
below
这是我的 spec_helper.rb:
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
#require 'spork/ext/ruby-debug'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
config.mock_with :mocha
#config.mock_with MultiMock::Adapter.for(:rspec, :mocha) #, :rr, :not_a_mock, ::NewMockFramework::RSpecAdapter)
# config.mock_with :flexmock
# config.mock_with :rr
#config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
end
end
Spork.each_run do
include Devise::TestHelpers
require 'factory_girl_rails'
# reload all the models
Dir["#{Rails.root}/app/models/**/*.rb"].each do |model|
load model
end
# reload all factories
FactoryGirl.factories.clear
Dir.glob("#{::Rails.root}/spec/factories/*.rb").each do |file|
load "#{file}"
end
# reload routes
Hope::Application.reload_routes!
end
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
RSpec.configure do |config|
config.extend ControllerMacros, :type => :controller
end
那么,我在这里缺少什么?
编辑
这是完整的错误:
04:28:30 - INFO - Starting Spork for RSpec
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
*** Mocha deprecation warning: Test::Unit or MiniTest must be loaded *before* Mocha.
*** Mocha deprecation warning: If you're integrating with a test library other than Test::Unit or MiniTest, you should use `require 'mocha/api'` instead of `require 'mocha'`.
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /home/dcaclab/RubymineProjects/coursebuilder/config/environment.rb:5)
[DEVISE] Devise.use_salt_as_remember_token is deprecated and has no effect. Please remove it.
Rack::File headers parameter replaces cache_control after Rack 1.5.
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
*** Mocha deprecation warning: `require 'mocha/standalone'` has been deprecated. Please use `require 'mocha/api' instead.
cannot load such file -- mocha/object (LoadError)
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/rspec-core-2.9.0/lib/rspec/core/mocking/with_mocha.rb:2:in `<top (required)>'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:315:in `mock_with'
/home/dcaclab/RubymineProjects/coursebuilder/spec/spec_helper.rb:26:in `block (2 levels) in <top (required)>'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/rspec-core-2.9.0/lib/rspec/core.rb:94:in `configure'
/home/dcaclab/RubymineProjects/coursebuilder/spec/spec_helper.rb:21:in `block in <top (required)>'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork.rb:24:in `prefork'
/home/dcaclab/RubymineProjects/coursebuilder/spec/spec_helper.rb:6:in `<top (required)>'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/app_framework/rails.rb:8:in `preload'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/test_framework.rb:134:in `block in preload'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork.rb:62:in `exec_prefork'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/test_framework.rb:120:in `preload'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:25:in `preload'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/runner.rb:74:in `run'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/lib/spork/runner.rb:10:in `run'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/gems/spork-0.9.2/bin/spork:10:in `<top (required)>'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/bin/spork:19:in `load'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/bin/spork:19:in `<main>'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/bin/ruby_noexec_wrapper:14:in `eval'
/home/dcaclab/.rvm/gems/ruby-1.9.3-p362@course_builder/bin/ruby_noexec_wrapper:14:in `<main>'
编辑 2
这是我的 Gemfile
source 'http://rubygems.org'
gem 'rails' , '3.2.11'
gem "heroku"
gem 'thin'
gem 'devise'#, '1.5.2'
gem 'will_paginate', '~> 3.0.2'
#gem 'nested_form', :git => 'git://github.com/fxposter/nested_form.git'
gem "simple_form"
gem "cancan"
gem 'kaminari'
gem 'foreigner'
gem "cocoon"
gem 'client_side_validations'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'#, " ~> 3.1.0"
gem 'coffee-rails'#, "~> 3.1.0"
gem 'uglifier'
end
gem "jquery-rails"
gem "validate_url", "~> 0.2.0"
gem 'pg', :group => [:production]
gem 'haml'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test, :development do
gem 'sqlite3'
gem 'turn', :require => false
gem "letter_opener"
gem 'meta_request', '0.2.0'
gem "rspec-rails", "2.9.0"
gem 'guard-rspec'
gem "spork"
gem 'guard-spork'
gem 'rb-inotify', '~> 0.8.8'
gem "factory_girl_rails"
gem "mocha", :require=> false
gem 'capybara' #, :git => 'git://github.com/jnicklas/capybara.git'
gem 'launchy'
gem "capybara-webkit"
gem "nifty-generators"
gem 'sextant'
gem 'haml-rails'
gem 'hpricot'
gem 'ruby_parser'
#gem 'rspec-multi-mock', :git => 'git://github.com/endeepak/rspec-multi-mock.git'
end
group :test do
#gem 'ruby-debug19', :require => 'ruby-debug'
end
gem 'execjs'
gem 'therubyracer'
这是我的 Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.11)
actionpack (= 3.2.11)
mail (~> 2.4.4)
actionpack (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.11)
activesupport (= 3.2.11)
builder (~> 3.0.0)
activerecord (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.11)
activemodel (= 3.2.11)
activesupport (= 3.2.11)
activesupport (3.2.11)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
ansi (1.4.3)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.4)
cancan (1.6.8)
capybara (2.0.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
capybara-webkit (0.14.1)
capybara (~> 2.0, >= 2.0.2)
json
childprocess (0.3.7)
ffi (~> 1.0, >= 1.0.6)
client_side_validations (3.2.1)
cocoon (1.1.2)
coderay (1.0.8)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.4.0)
daemons (1.1.9)
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0)
excon (0.16.10)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.2.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.2.0)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
ffi (1.3.1)
foreigner (1.3.0)
activerecord (>= 3.0.0)
guard (1.6.2)
listen (>= 0.6.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
terminal-table (>= 1.4.3)
thor (>= 0.14.6)
guard-rspec (1.2.1)
guard (>= 1.1)
guard-spork (1.4.1)
childprocess (>= 0.2.3)
guard (>= 1.1)
spork (>= 0.8.4)
haml (3.1.7)
haml-rails (0.3.5)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (~> 3.1)
railties (>= 3.1, < 4.1)
heroku (2.34.0)
heroku-api (~> 0.3.7)
launchy (>= 0.3.2)
netrc (~> 0.7.7)
rest-client (~> 1.6.1)
rubyzip
heroku-api (0.3.7)
excon (~> 0.16.10)
hike (1.2.1)
hpricot (0.8.6)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.2.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.6)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
launchy (2.1.2)
addressable (~> 2.3)
letter_opener (1.0.0)
launchy (>= 2.0.4)
libv8 (3.11.8.13)
listen (0.7.2)
lumberjack (1.0.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_request (0.2.0)
rack-contrib
rails
metaclass (0.0.1)
method_source (0.8.1)
mime-types (1.19)
mocha (0.13.2)
metaclass (~> 0.0.1)
multi_json (1.5.0)
netrc (0.7.7)
nifty-generators (0.4.6)
nokogiri (1.5.6)
orm_adapter (0.4.0)
pg (0.14.1)
polyglot (0.3.3)
pry (0.9.11.4)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.4.4)
rack-cache (1.2)
rack (>= 0.4)
rack-contrib (1.1.0)
rack (>= 0.9.1)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.11)
actionmailer (= 3.2.11)
actionpack (= 3.2.11)
activerecord (= 3.2.11)
activeresource (= 3.2.11)
activesupport (= 3.2.11)
bundler (~> 1.0)
railties (= 3.2.11)
railties (3.2.11)
actionpack (= 3.2.11)
activesupport (= 3.2.11)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
rdoc (3.12)
json (~> 1.4)
ref (1.0.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.9.0)
rspec-core (~> 2.9.0)
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.9.0)
ruby_parser (3.1.1)
sexp_processor (~> 4.1)
rubyzip (0.9.9)
sass (3.2.5)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
selenium-webdriver (2.29.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
sexp_processor (4.1.4)
sextant (0.2.3)
activesupport (>= 3.2)
rails (>= 3.2)
simple_form (2.0.4)
actionpack (~> 3.0)
activemodel (~> 3.0)
slop (3.4.3)
spork (0.9.2)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
terminal-table (1.4.5)
therubyracer (0.11.3)
libv8 (~> 3.11.8.12)
ref
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.17.0)
tilt (1.3.3)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
turn (0.9.6)
ansi
tzinfo (0.3.35)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
validate_url (0.2.0)
activemodel (>= 3.0.0)
warden (1.2.1)
rack (>= 1.0)
websocket (1.0.7)
will_paginate (3.0.4)
xpath (1.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
cancan
capybara
capybara-webkit
client_side_validations
cocoon
coffee-rails
devise
execjs
factory_girl_rails
foreigner
guard-rspec
guard-spork
haml
haml-rails
heroku
hpricot
jquery-rails
kaminari
launchy
letter_opener
meta_request (= 0.2.0)
mocha
nifty-generators
pg
rails (= 3.2.11)
rb-inotify (~> 0.8.8)
rspec-rails (= 2.9.0)
ruby_parser
sass-rails
sextant
simple_form
spork
sqlite3
therubyracer
thin
turn
uglifier
validate_url (~> 0.2.0)
will_paginate (~> 3.0.2)
最佳答案
如这里所说:https://github.com/freerange/mocha#bundler ,您需要确保 Mocha 不是自动必需的,然后在 spec_helper.rb
所以你的 Gemfile
应该有这样的东西:
gem "mocha", :require => false
然后你的 spec_helper.rb
应该有以下内容(在你的其他要求没问题之后):
require "mocha/setup"
关于rspec - 无法加载此类文件 -- mocha/object (LoadError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14588424/
我想要显示正在加载的 .gif,直到所有内容都已加载,包括嵌入的 iframe。但是,目前加载 gif 会在除 iframe 之外的所有内容都已加载后消失。我怎样才能让它等到 iframe 也加载完毕
首先,这是我第一次接触 Angular。 我想要实现的是,我有一个通知列表,我必须以某种方式限制 limitTo,因此元素被限制为三个,在我单击按钮后,其余的应该加载。 我不明白该怎么做: 设置“ V
我正在尝试在我的设备上运行这个非常简单的应用程序(使用 map API V2),并且出于某种原因尝试使用 MapView 时: 使用 java 文件: public class MainMap e
我正在使用 Python 2.6、Excel 2007 Professional 和最新版本的 PyXLL。在 PyXLL 中加载具有 import scipy 抛出异常,模块未加载。有没有人能够在
我想做这个: 创建并打包原始游戏。然后我想根据原始游戏中的蓝图创建具有新网格/声音/动画和蓝图的其他 PAK 文件。原始游戏不应该知道有关其他网格/动画/等的任何信息。因此,我需要在原始游戏中使用 A
**摘要:**在java项目中经常会使用到配置文件,这里就介绍几种加载配置文件的方法。 本文分享自华为云社区《【Java】读取/加载 properties配置文件的几种方法》,作者:Copy工程师。
在 Groovy 脚本中是否可以执行条件导入语句? if (test){ import this.package.class } else { import that.package.
我正在使用 NVidia 视觉分析器(来自 CUDA 5.0 beta 版本的基于 eclipse 的版本)和 Fermi 板,我不了解其中两个性能指标: 全局加载/存储效率表示实际内存事务数与请求事
有没有办法在通过 routeProvider 加载特定 View 时清除 Angular JS 存储的历史记录? ? 我正在使用 Angular 创建一个公共(public)安装,并且历史会积累很多,
使用 Xcode 4.2,在我的应用程序中, View 加载由 segue 事件触发。 在 View Controller 中首先调用什么方法? -(void) viewWillAppear:(BOO
我在某些Django模型中使用JSONField,并希望将此数据从Oracle迁移到Postgres。 到目前为止,当使用Django的dumpdata和loaddata命令时,我仍然没有运气来保持J
创建 Nib 时,我需要创建两种类型:WindowNib 或 ViewNib。我看到的区别是,窗口 Nib 有一个窗口和一个 View 。 如何将 View Nib 加载到另一个窗口中?我是否必须创建
我想将多个env.variables转换为静态结构。 我可以手动进行: Env { is_development: env::var("IS_DEVELOPMENT")
正如我从一个测试用例中看到的:https://godbolt.org/z/K477q1 生成的程序集加载/存储原子松弛与普通变量相同:ldr 和 str 那么,宽松的原子变量和普通变量之间有什么区别吗
我有一个重定向到外部网站的按钮/链接,但是外部网站需要一些时间来加载。所以我想添加一个加载屏幕,以便外部页面在显示之前完全加载。我无法控制外部网站,并且外部网站具有同源策略,因此我无法在 iFrame
我正在尝试为我的应用程序开发一个Dockerfile,该文件在初始化后加载大量环境变量。不知何故,当我稍后执行以下命令时,这些变量是不可用的: docker exec -it container_na
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我刚刚遇到一个问题,我有一个带有一些不同选项的选择标签。 现在我想检查用户选择了哪些选项。 然后我想将一个新的 html 文件加载到该网站(取决于用户选中的选项)宽度 javascript,我该怎么做
我知道两种保存/加载应用程序设置的方法: 使用PersistentStore 使用文件系统(存储,因为 SDCard 是可选的) 我想知道您使用应用程序设置的做法是什么? 使用 PersistentS
我开始使用 Vulkan 时偶然发现了我的第一个问题。尝试创建调试报告回调时(验证层和调试扩展在我的英特尔 hd vulkan 驱动程序上可用,至少它是这么说的),它没有告诉我 vkCreateDeb
我是一名优秀的程序员,十分优秀!