我在ruby-1.9.2-p180上运行rails 2.3.14
我正在尝试让 guard rspec 运行。
我安装了相关的gems,这是我的文件内容,用于Gemfile、/spec/spec_helper.rb和Guardfile
宝石文件
group :test, :development do
gem 'rspec-rails', '~> 1.3.2', :require => false
gem 'simplecov', :require => false
end
group :test do
gem 'test-unit', '1.2.3', :require => false # for rspec
gem 'rspec', '~> 1.3.2', '~> 1.2', :require => false
gem 'guard', :require => false
gem 'rb-inotify', '~> 0.9', :require => false
gem 'spork', '~> 0.8', :require => false
gem 'guard-rspec', :require => false
gem 'guard-spork', :require => false
gem 'growl', :require => false # notifications; optional
gem 'listen', '>= 0.5.1', :require => false
gem 'machinist', '~> 2.0', :require => false
gem 'database_cleaner', '~> 0.9.1', :require => false
end
spec_helper.rb
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
end
Spork.each_run do
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
end
Spec::Runner.configure do |config|
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
end
保护文件
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end
guard 'rspec', :version => 1 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
当我跑
耙规格
它工作正常
但是当我跑步时
警卫
它向我显示了这个错误
13:04:24 - INFO - Guard uses NotifySend to send notifications.
13:04:24 - INFO - Guard uses TerminalTitle to send notifications.
13:04:24 - INFO - Starting Spork for RSpec
Using RSpec
Preloading Rails environment
no such file to load -- /home/francois/sites/easylodge/config/application (LoadError)
更新
当我在Guardfile中注释掉这部分时,它看起来启动正常
# guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
# watch('config/application.rb')
# watch('config/environment.rb')
# watch('config/environments/test.rb')
# watch(%r{^config/initializers/.+\.rb$})
# watch('Gemfile')
# watch('Gemfile.lock')
# watch('spec/spec_helper.rb') { :rspec }
# watch('test/test_helper.rb') { :test_unit }
# watch(%r{features/support/}) { :cucumber }
# end
导致控制台
13:17:01 - INFO - Guard uses NotifySend to send notifications.
13:17:01 - INFO - Guard uses TerminalTitle to send notifications.
13:17:01 - INFO - Guard::RSpec is running, with RSpec 1!
13:17:01 - INFO - Running all specs
13:17:07 - INFO - Guard is now watching at '/home/francois/sites/easylodge'