解決済み:ガードファイル内のスポークコードを取り出し、スポークとガードで動作する別のアプリから動作中のガードファイルをコピーして貼り付けました。
GuardとSporkをアプリにインストールしました。Guardは正常に機能しますが、Sporkを実行すると、Sporkが読み込まれ、準備ができて聞いていると表示されます。新しいターミナルを開いてrspecを起動するとすぐに、最初のターミナルでSporkが強制終了され、これが表示されます...
jason@jason:~/ror/blog$ guard
14:57:44 - INFO - Guard here! It looks like your project has a Gemfile, yet you are
running
> [#] `guard` outside of Bundler. If this is your intent, feel free to ignore this
> [#] message. Otherwise, consider using `bundle exec guard` to ensure your
> [#] dependencies are loaded correctly.
> [#] (You can run `guard` with --no-bundler-warning to get rid of this message.)
14:57:45 - INFO - Guard uses NotifySend to send notifications.
14:57:45 - INFO - Guard uses TerminalTitle to send notifications.
14:57:45 - INFO - Guard is now watching at '/home/jason/ror/blog'
14:57:45 - INFO - Starting Spork for RSpec
Using RSpec
Preloading Rails environment
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded
2.8.0
Loading Spork.prefork block...
Spork is ready and listening on 8989!
14:58:02 - INFO - Spork server for RSpec successfully started
14:58:03 - INFO - Guard::RSpec is running, with RSpec 2!
14:58:03 - INFO - Running all specs
元の端末では、これが表示されます...
jason@jason:~/ror/blog$ spork
Using RSpec
Preloading Rails environment
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded
2.8.0
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Killed
jason@jason:~/ror/blog$
これが私のspec_helperファイルです
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# config.mock_with :mocha
# 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"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
end
Spork.each_run do
FactoryGirl.reload
end
これが私のGuardfileです
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'active_support/core_ext'
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV'
=> 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('spec/spec_helper.rb')
watch(%r{^spec/support/.+\.rb$})
end
guard 'rspec', :version => 2, :all_after_pass => false 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
私のgemfileには
group :test do
gem 'capybara', '1.1.2'
gem 'rb-inotify', '0.8.8'
gem 'libnotify', '0.5.9'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
end
group :development, :test do
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.1'
gem 'guard-spork', '1.2.0'
gem 'spork', '0.9.2'
end
動作しているように見えますが、テストには同じ時間がかかるため、sporkが動作しないことはわかっています。