Ruby rspec<;顶部(必需)>;错误-没有其他好信息-根本原因是什么?
以下是我的设置: rails 3.12.2、rspec 2.13.1、spork 0.9.2、mysql gem 0.3.11。我是RoR和rspec的新手 我在后台运行spork,spork中未报告任何问题 当我使用以下工具运行模型测试时:Ruby rspec<;顶部(必需)>;错误-没有其他好信息-根本原因是什么?,ruby,rspec,ruby-on-rails-3.2,rspec-rails,spork,Ruby,Rspec,Ruby On Rails 3.2,Rspec Rails,Spork,以下是我的设置: rails 3.12.2、rspec 2.13.1、spork 0.9.2、mysql gem 0.3.11。我是RoR和rspec的新手 我在后台运行spork,spork中未报告任何问题 当我使用以下工具运行模型测试时: rake规范:模型——跟踪 我得到以下结果: Invoke spec:models (first_time) Invoke test:prepare (first_time) Invoke db:test:prepare (first_time)
rake规范:模型——跟踪
我得到以下结果:
Invoke spec:models (first_time)
Invoke test:prepare (first_time)
Invoke db:test:prepare (first_time)
Invoke db:abort_if_pending_migrations (first_time)
Invoke environment (first_time)
Execute environment
Invoke db:load_config (first_time)
Execute db:load_config
Execute db:abort_if_pending_migrations
Execute db:test:prepare
Invoke db:test:load (first_time)
Invoke db:test:purge (first_time)
Invoke environment
Invoke db:load_config
Execute db:test:purge
Execute db:test:load
Invoke db:test:load_schema (first_time)
Invoke db:test:purge
Execute db:test:load_schema
Invoke db:schema:load (first_time)
Invoke environment
Invoke db:load_config
Execute db:schema:load
Execute test:prepare
Execute spec:models
ruby.exe -S rspec ./spec/models/user_spec.rb
..
Finished in 0.51565 seconds
2 examples, *0 failures*
Randomized with seed 540
<-- Slave(1) run done!
**rake aborted!**
ruby.exe -S rspec ./spec/models/user_spec.rb **failed**
/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:156:in `run_task'
/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:124:in `block (2 levels) in initialize'
....
/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
ruby/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `**<top (required)>**'
bin/rake:19:in `load'
bin/rake:19:in `<main>'
Tasks: TOP => spec:models
以下是spec_helper.rb的内容:
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# 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|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end
那么,当使用spork运行时,上面的“top required”错误的根本原因是什么?我是否提供了确定根本原因所需的一切
我看了其他问题(),但它们不是同一个问题
蒂亚
Scott如果在没有运行spork服务器的情况下运行同一命令,会发生什么?使用spork运行会导致问题。那就是如果我没有斯波克的话,它会工作的!我将把我的问题编辑为如何让spork工作。:)修改了我的问题,问为什么spork测试失败,但如果spork没有运行,就不要失败。我还添加了rspec助手ruby代码。
require 'spork'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# 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|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
end
end
Spork.each_run do
# This code will be run each time you run your specs.
end