gpt4 book ai didi

ruby-on-rails - 带有 spork 的未初始化常量 RSpec

转载 作者:太空宇宙 更新时间:2023-11-03 16:30:40 27 4
gpt4 key购买 nike

我正在尝试让 spork 与 Rails 2.3.18 应用程序一起工作

这是我的 gemfile 的一部分,显示了 Rspec 版本:

gem "rails", "2.3.18"
gem "haml", "3.1.8"
gem "twitter", :git => "git://github.com/sferik/twitter.git", :tag => "v0.9.12"
gem 'rdoc', '~> 3.9.2'

group :test, :development do
gem "rspec", "1.3.1"
# gem 'rspec-mocks', '2.1.0'
# gem 'rspec-core', '2.1.0'
# gem 'rspec-expectations', '2.1.0'
gem "rspec-rails", "1.3.4"
# gem 'guard'
# gem 'guard-livereload'
# gem 'rb-fsevent', '~> 0.9'
# gem 'em-websocket'
gem 'spork'
end

这是我的 spec_helper.rb

require 'rubygems'
require 'spork'
#require 'spork/ext/ruby-debug'

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.

# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'

# Uncomment the next line to use webrat's matchers
#require 'webrat/integrations/rspec-rails'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}

Spec::Runner.configure do |config|
# If you're not using ActiveRecord you should remove these
# lines, delete config/database.yml and disable :active_record
# in your config/boot.rb
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'

# == Fixtures
#
# You can declare fixtures for each example_group like this:
# describe "...." do
# fixtures :table_a, :table_b
#
# Alternatively, if you prefer to declare them only once, you can
# do so right here. Just uncomment the next line and replace the fixture
# names with your fixtures.
#
# config.global_fixtures = :table_a, :table_b
#
# If you declare global fixtures, be aware that they will be declared
# for all of your examples, even those that don't use them.
#
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
#
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
#
# == Mock Framework
#
# RSpec uses its own mocking framework by default. If you prefer to
# use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
#
# == Notes
#
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
end

end

Spork.each_run do
# This code will be run each time you run your specs.

end

# --- Instructions ---
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
# block.
#
# The Spork.prefork block is run only once when the spork server is started.
# You typically want to place most of your (slow) initializer code in here, in
# particular, require'ing any 3rd-party gems that you don't normally modify
# during development.
#
# The Spork.each_run block is run each time you run your specs. In case you
# need to load files that tend to change during development, require them here.
# With Rails, your application modules are loaded automatically, so sometimes
# this block can remain empty.
#
# Note: You can modify files loaded *from* the Spork.each_run block without
# restarting the spork server. However, this file itself will not be reloaded,
# so if you change any of the code inside the each_run block, you still need to
# restart the server. In general, if you have non-trivial code in this file,
# it's advisable to move it into a separate file so you can easily edit it
# without restarting spork. (For example, with RSpec, you could move
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
# spec/support/* files are require'd from inside the each_run block.)
#
# Any code that is left outside the two blocks will be run during preforking
# *and* during each_run -- that's probably not what you want.
#
# These instructions should self-destruct in 10 seconds. If they don't, feel
# free to delete them.

Spork 启动成功。

当我运行时

./script/spec spec 

测试成功运行。但是,如果我像这样传递 --drb 选项

./script/spec spec --drb 

我明白了

Exception encountered: #<NameError: uninitialized constant RSpec> 

最佳答案

必须使用 gem 'spork', '~> 0.8.0'

关于ruby-on-rails - 带有 spork 的未初始化常量 RSpec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16597792/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com