我在spork中运行rspec --drb时遇到问题: 在ruby文件(项目或规范文件)中出现任何语法错误后,看起来像守卫停止运行rspec命令并跟踪更改。
当我从没有spork(并且没有 - drb)的后卫运行rspec时,它工作正常。 此外spork + rspec工作正常,然后没有后卫
错误:
.nav-primary .child-container li.level1 {
float: left;
display: block;
width: 190px;
min-height: 138px;
margin: 10px;
line-height: 1.5em;
}
的Gemfile:
18:18:19 - INFO - Run all
18:18:20 - INFO - Running all specs
Running tests with args ["--color", "--failure-exit-code", "2", "--format", "documentation", "--format", "Guard::RSpecFormatter", "--require", "spec_helper", "--require", "/home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec_formatter.rb", "spec"]...
Exception encountered: #<SyntaxError: /media/sf_win-sites/Intelinets/happiness/app/models/product.rb:3: syntax error, unexpected tIDENTIFIER, expecting keyword_end
1validates :price , numericality: true #{greater_than: 0}
^>
backtrace:
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `require'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `block in require'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `require'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:348:in `require_or_load'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:480:in `load_missing_constant'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:180:in `const_missing'
/media/sf_win-sites/Intelinets/happiness/spec/models/product_spec.rb:2:in `<top (required)>'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:241:in `load'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:241:in `block in load'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:241:in `load'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
/home/sphinx/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/test_framework/rspec.rb:12:in `run_tests'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/run_strategy/forking.rb:13:in `block in run'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/forker.rb:21:in `block in initialize'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/forker.rb:18:in `fork'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/forker.rb:18:in `initialize'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/run_strategy/forking.rb:9:in `new'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/run_strategy/forking.rb:9:in `run'
/home/sphinx/.rvm/gems/ruby-2.1.5/bundler/gems/spork-224df492657e/lib/spork/server.rb:49:in `run'
/home/sphinx/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/drb/drb.rb:1588:in `perform_without_block'
/home/sphinx/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/drb/drb.rb:1548:in `perform'
/home/sphinx/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/drb/drb.rb:1626:in `block (2 levels) in main_loop'
/home/sphinx/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/drb/drb.rb:1622:in `loop'
/home/sphinx/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/drb/drb.rb:1622:in `block in main_loop'
Done.
18:18:22 - ERROR - Guard::RSpec failed to achieve its <run_all>, exception was:
> [#ede981094807] Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/rspec_guard_result
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `readlines'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `initialize'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `new'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `_read_results'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:17:in `initialize'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `new'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `_really_run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:57:in `_run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:34:in `run_all'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:33:in `block in run_all'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:48:in `_throw_if_failed'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:33:in `run_all'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:82:in `block in _supervise'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:79:in `catch'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:79:in `_supervise'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:22:in `block (3 levels) in run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:119:in `block (2 levels) in _run_group_plugins'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:117:in `each'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:117:in `block in _run_group_plugins'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:116:in `catch'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:116:in `_run_group_plugins'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:21:in `block (2 levels) in run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:20:in `each'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:20:in `block in run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/lumberjack-1.0.10/lib/lumberjack.rb:32:in `unit_of_work'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/runner.rb:18:in `run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/commander.rb:82:in `run_all'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/internals/queue.rb:42:in `block in _run_actions'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/internals/queue.rb:37:in `each'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/internals/queue.rb:37:in `_run_actions'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/internals/queue.rb:21:in `process'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/commander.rb:43:in `start'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/cli.rb:122:in `start'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:32:in `execute'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#ede981094807] /home/sphinx/.rvm/gems/ruby-2.1.5/gems/guard-2.13.0/bin/_guard-core:11:in `<main>'
18:18:22 - INFO - Guard::RSpec has just been fired
spec_helper:
group :development, :test do
gem 'rspec-rails', '~> 3.0'
gem 'capybara'
gem 'guard-rspec', require: false
gem 'sqlite3'
# gem 'guard-livereload'
gem 'spork', github: 'sporkrb/spork'
gem 'spork-rails', github: 'sporkrb/spork-rails' # rubygems version not rails 4 compatible
gem 'guard-spork', :github => 'guard/guard-spork'
# gem 'childprocess'
gem 'factory_girl_rails'
gem 'database_cleaner'
gem 'minitest'
gem 'shoulda-matchers', '2.5.0'
end
guardfile:
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require "shoulda/matchers"
ActiveRecord::Migration.maintain_test_schema!
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
end
Spork.each_run do
end
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
end
.rspec:
guard :rspec, :cmd => "rspec --drb" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
# Feel free to open issues for suggestions and improvements
# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)
# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)
watch(rails.controllers) do |m|
[
rspec.spec.("routing/#{m[1]}_routing"),
rspec.spec.("controllers/#{m[1]}_controller"),
rspec.spec.("acceptance/#{m[1]}")
]
end
# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end
end
guard :spork, :rspec_env => { 'RAILS_ENV' => 'test' }, test_unit: false do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
# watch('test/test_helper.rb') { :test_unit }
# watch(%r{features/support/}) { :cucumber }
end
答案 0 :(得分:0)
就个人而言,我建议您从spork切换到spring或zeus。
但这与此处的问题无关。
首先,最好在guard-rspec的GitHub页面上打开问题。 (您可能会获得更快的响应,并且您可以跟踪修补程序何时正式发布)。
问题出在这里:
18:18:22 - ERROR - Guard::RSpec failed to achieve its <run_all>, exception was:
> [#ede981094807] Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/rspec_guard_result
由于某些原因,guard-rspec
无法打开其结果文件。
我猜测它是因为当您使用--drb
运行rspec时,失败并未报告给Guard-RSpec(通过Guard::RSpecFormatter
类)。< / p>
所以我不确定rspec --drb是否可以在这里工作。您可以尝试更新版本的RSpec,看看它是否有帮助。
如果您可以设置一个小型仓库来重现问题并在https://github.com/guard/guard-rspec/issues/new中打开一个问题,我可以看看。