guard / guard-rspec

Guard::RSpec automatically run your specs (much like autotest)
https://rubygems.org/gems/guard-rspec
MIT License
1.31k stars 241 forks source link

Guard::RSpec cannot open results file #400

Open pollcaz opened 7 years ago

pollcaz commented 7 years ago

18:02:24 - ERROR - Guard::RSpec failed to achieve its , exception was:

[#47fcf89845a4] Errno::ENOENT: No such file or directory @ rb_sysopen

I'm using guard + rspec + spring + rubocop in my Gemfile I have this gems:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use thin as the app server
# TODO Change it to use puma (the default rails 5 app server)? Right now using thin since is  the app server configured in staging
gem 'thin'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'dotenv-rails'
# Devise 
gem 'devise'
gem 'devise_invitable'
# ActiveAdmin
gem 'activeadmin', github: 'activeadmin'
gem 'inherited_resources', github: 'activeadmin/inherited_resources'
gem 'ransack',             github: 'activerecord-hackery/ransack'
gem 'draper',              '> 3.x'
#gem 'sass-rails',          github: 'rails/sass-rails' # For Sprockets 4
# Serializer
gem 'active_model_serializers'
gem 'aasm' 
# Payments
gem 'stripe'
# Paper trail  #track of models
gem 'paper_trail'
# cron
gem 'whenever', require: false
#pdf
gem 'prawn'
gem 'prawn-labels'
#attachments
gem "paperclip"
#aws
gem 'aws-sdk'
#resque
gem 'resque'
gem 'resque-retry'
gem "capistrano-resque", "~> 0.2.2", require: false
#slim
gem 'slim'
# Other gems
gem 'bson', '~> 3.2.6'
# gems for charts
gem 'chartkick', '~> 1.2.4'
gem 'groupdate', '~> 2.1.1'
gem 'active_median', '~> 0.1.0'
gem "bugsnag"
gem 'font-awesome-sass', '~> 4.7.0'
gem 'rack-cors', :require => 'rack/cors'
gem 'sinatra', github: 'sinatra'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
  gem 'rspec-rails'

  # FactoryGirl to create model stubs.
  gem 'factory_girl_rails'
# Faker to generate test data.
  gem 'faker'
  gem 'guard-rspec', '~> 4.7.3'
  gem 'guard-rubocop', '~> 1.2.0'
  gem 'rubocop', '~> 0.48.1'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Capistrano stuff
  gem 'capistrano', '~> 3.6.1'
  gem 'capistrano-rails'
  gem 'capistrano-bundler'
  gem 'capistrano-rbenv'
end

group :test do
  # DatabaseCleaner for cleaning up the test database.
  gem 'database_cleaner'

  # Shoulda to make life easier.
  gem 'shoulda'

  # Provides the its method as a short-hand to specify the expected value
  # of an attribute.
  gem 'rspec-its'

  #Mocks for stripe
  gem 'stripe-ruby-mock'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

when I try to run all test guard raises many exceptions

8:07:49 - INFO - Guard::RSpec is running
18:07:50 - INFO - Guard is now watching at '/home/pcarmona-dk/apps/rails/onwarddev/mooshme-api'
[1] guard(main)> 
18:07:50 - INFO - Run all
18:07:50 - INFO - Running all specs
Version: 2.0.0

Usage: spring COMMAND [ARGS]

Commands for spring itself:

  binstub         Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert.
  help            Print available commands.
  server          Explicitly start a Spring server in the foreground
  status          Show current status.
  stop            Stop all spring processes for this project.

Commands for your application:

  rails           Run a rails command. The following sub commands will use spring: console, runner, generate, destroy, test.
  rake            Runs the rake command
18:07:51 - ERROR - Guard::RSpec cannot open results file: "/home/pcarmona-dk/apps/rails/onwarddev/mooshme-api/tmp/rspec_guard_result". This is likely a bugso please report this at http://github.com/guard/guard-rspec/issues/new along with as muchinformation as possible to reproduce this issue.
18:07:51 - ERROR - Guard::RSpec failed to achieve its <run_all>, exception was:
> [#6ea80a09d7bf] Errno::ENOENT: No such file or directory @ rb_sysopen - /home/pcarmona-dk/apps/rails/onwarddev/mooshme-api/tmp/rspec_guard_result
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/results.rb:11:in `readlines'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/results.rb:11:in `initialize'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/rspec_process.rb:57:in `new'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/rspec_process.rb:57:in `_read_results'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/rspec_process.rb:18:in `initialize'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/runner.rb:65:in `new'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/runner.rb:65:in `_really_run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/runner.rb:54:in `_run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec/runner.rb:31:in `run_all'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec.rb:33:in `block in run_all'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec.rb:48:in `_throw_if_failed'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-rspec-4.7.3/lib/guard/rspec.rb:33:in `run_all'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:83:in `block (2 levels) in _supervise'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/ui/config.rb:62:in `block in with_progname'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/lumberjack-1.0.12/lib/lumberjack/logger.rb:270:in `push_thread_local_value'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/lumberjack-1.0.12/lib/lumberjack/logger.rb:231:in `set_progname'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/ui/config.rb:61:in `with_progname'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:81:in `block in _supervise'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:79:in `catch'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:79:in `_supervise'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:22:in `block (3 levels) in run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:121:in `block (2 levels) in _run_group_plugins'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:119:in `each'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:119:in `block in _run_group_plugins'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:118:in `catch'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:118:in `_run_group_plugins'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:21:in `block (2 levels) in run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:20:in `each'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:20:in `block in run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/lumberjack-1.0.12/lib/lumberjack.rb:32:in `unit_of_work'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/runner.rb:18:in `run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/commander.rb:82:in `run_all'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/internals/queue.rb:43:in `block in _run_actions'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/internals/queue.rb:38:in `each'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/internals/queue.rb:38:in `_run_actions'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/internals/queue.rb:22:in `process'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/commander.rb:43:in `start'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/cli.rb:122:in `start'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/aruba_adapter.rb:32:in `execute'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#6ea80a09d7bf] /home/pcarmona-dk/.rbenv/versions/2.3.1/gemsets/mooshme-api/gems/guard-2.14.1/bin/_guard-core:11:in `<main>'
18:07:51 - INFO - Guard::RSpec has just been fired

and my Guardfile is setting as follows:

group :red_green_refactor, halt_on_fail: true do
  guard :rspec, cmd: 'spring rspec'  do
    require 'guard/rspec/dsl'
    dsl = Guard::RSpec::Dsl.new(self)

    # 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 :rubocop, all_on_start: false do
    watch(%r{.+\.rb$})
    watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
  end
end
edruder commented 6 years ago

I just hit this with Rails 5.1. Similar gemset.

Initially, if I changed my newest example from using a before do...end to a subject {...}, the error stopped happening.

Nope. That was a temporary lack-of-crash--when I continued to add to the example, the crash returned. Playing more with before do...end, subject {...}, and neither, leads me to think there is no correlation.

It seems to be come and go as I change the example. Very maddening.

hoahm-ts commented 6 years ago

It worked for me

Ruby 2.3.3p222
gem 'spring'
gem 'spring-watcher-listen'
gem 'guard', '2.14.1'
gem 'guard-rspec', '4.6.4'

And in the Guard file:

guard :rspec, cmd: 'bundle exec rspec -o ./log/results.txt' do
  watch('spec/spec_helper.rb')                        { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$})          { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_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"] }
end
fjfish commented 6 years ago

I'm running 5.2

It looks like spring doesn't have the rspec command, and that's what the error really is, as in there is no file to open because it didn't run.

I fixed it by installing https://github.com/jonleighton/spring-commands-rspec