Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't fail when there are no spec files to be run #234

Merged
merged 1 commit into from
Dec 26, 2013

Conversation

yujinakayama
Copy link
Contributor

Currently guard-rspec throws :task_has_failed when there are no spec files to be run.
This change makes guard-rspec abort without failing in that case.

Example

Here's an Guardfile with a group with halt_on_fail option:

# This group allows to skip running RuboCop when RSpec failed.
group :red_green_refactor, halt_on_fail: true do
  guard :rspec, cmd: 'bundle exec rspec' do
    watch(%r{^spec/.+_spec\.rb$})
    watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
  end

  guard :rubocop do
    watch(%r{.+\.rb$})
  end
end

When I modified a library file that has no corresponding spec file (i.e. lib/foo.rb exists but spec/foo_spec.rb doesn't exist), guard-rspec fails and guard-rubocop won't run.

$ bundle exec guard --debug
23:33:15 - DEBUG - Command execution: emacsclient --eval '1' 2> /dev/null || echo 'N/A'
23:33:15 - INFO - Guard is using GNTP to send notifications.
23:33:15 - INFO - Guard is using TerminalTitle to send notifications.
23:33:15 - DEBUG - Command execution: hash stty
23:33:15 - DEBUG - Guard starts all plugins
23:33:15 - DEBUG - Hook :start_begin executed for Guard::RSpec
23:33:15 - INFO - Guard::RSpec is running
23:33:15 - DEBUG - Hook :start_end executed for Guard::RSpec
23:33:15 - DEBUG - Hook :start_begin executed for Guard::Rubocop
23:33:15 - DEBUG - Hook :start_end executed for Guard::Rubocop
23:33:15 - DEBUG - Hook :start_begin executed for Guard::Shell
23:33:15 - DEBUG - Hook :start_end executed for Guard::Shell
23:33:15 - INFO - Guard is now watching at '/tmp/transpec'
23:33:15 - DEBUG - Command execution: stty -g 2>/dev/null
23:33:15 - DEBUG - Start interactor
23:33:32 - DEBUG - Stop interactor
23:33:32 - DEBUG - Command execution: stty gfmt1:cflag=4b00:iflag=6b02:lflag=200005cb:oflag=3:discard=f:dsusp=19:eof=4:eol=ff:eol2=ff:erase=7f:intr=3:kill=15:lnext=16:min=1:quit=1c:reprint=12:start=11:status=14:stop=13:susp=1a:time=0:werase=17:ispeed=9600:ospeed=9600 2>/dev/null 
23:33:32 - DEBUG - Hook :run_on_modifications_begin executed for Guard::RSpec
23:33:32 - INFO - Guard::RSpec has failed, other group's plugins execution has been halted.
23:33:32 - DEBUG - Command execution: stty -g 2>/dev/null
23:33:32 - DEBUG - Start interactor

Actually I'm still not sure whether this is a specification or a bug, though I feel this is strange and inconvenient.
What do you think?

Environment

  • ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
  • guard 2.2.5
  • guard-rspec 4.2.0

Gemfile:

source 'https://rubygems.org'

gem 'guard-rspec',   '~> 4.0'
gem 'guard-rubocop', '~> 1.0'

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 53865bd on yujinakayama:dont-fail-with-no-target-file into 6e756dc on guard:master.

@thibaudgg
Copy link
Member

I think that is a pretty good PR, thanks!

thibaudgg added a commit that referenced this pull request Dec 26, 2013
Don't fail when there are no spec files to run
@thibaudgg thibaudgg merged commit 900eb21 into guard:master Dec 26, 2013
@yujinakayama yujinakayama deleted the dont-fail-with-no-target-file branch December 27, 2013 01:39
@yujinakayama
Copy link
Contributor Author

Thanks!

thibaudgg added a commit that referenced this pull request Jan 9, 2014
Fix #234
Rerun failed spec with example groups in different files does not work.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants