New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guard is running wrong specs when used with spring #272
Comments
It's probably best to poke around a little to figure out what exactly you're expecting and what you're getting:
def _run(all, paths, options)
command = Command.new(paths, options)
STDERR.puts "Running Rspec: #{command.inspect}"
_without_bundler_env { Kernel.system(command) }.tap do |success| Running that command should reproduce the same problem outside guard, which could help work out where the problem is. That's because many things can influence how everything behaves, so it's best to first work out how Rspec is actually invoked in your case. Personally I use zeus instead of spring - but everything should work fine regardless, so it's good you're bringing this up. |
Yeah, so it's just listing the same set of files regardless of what file I modify, i.e. I modify user_spec.rb and instead I get this:
When running without spring it works fine, just re-runs user_spec.rb. Adding the debug statement above also shows the same files being modified: `Running Rspec: "spring rspec spec -f doc -r /home/ibrahim/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/guard-rspec-4.2.10/lib/guard/rspec/formatter.rb -f Guard::RSpec::Formatter --failure-exit-code 2 ./spec/mailers/user_mailer_spec.rb:8 ./spec/models/assignment_spec.rb:43 ./spec/models/assignment_spec.rb:48 ./spec/models/assignment_spec.rb:52 ./spec/models/assignment_spec.rb:67 ./spec/models/assignment_spec.rb:71 ./spec/models/assignment_spec.rb:75 ./spec/models/course_spec.rb:88 ./spec/models/free_response_question_spec.rb:34 ./spec/models/free_response_question_spec.rb:38 ./spec/models/free_response_question_spec.rb:42" So, could it be a bug in guard? |
Hmm, I've narrowed it down a bit: Looks like when run(paths) is called, the path is correct, and somehow the inspector is getting confused. I inserted a debug statement above this line and the paths argument is the file that was modified only (which makes sense). https://github.com/guard/guard-rspec/blob/master/lib/guard/rspec/runner.rb#L25 And then after that it prints out the incorrect list of paths. |
Could you try setting a inspector specifically in the Guardfile, such as The README says |
Ah yeah, it seems to be the FocusedInspector (I printed out inspector.class). I tried adding failed_mode: :none, and it re-ran everything. It said
and then proceeds to run all specs. |
Either way, guard-rspec needs better logging/debugging - I should get to fixing that at some point... |
Thanks for reporting this and taking the time to dig in! |
Aha! I figured out the solution for my specific case. I had command line specified as
because somewhere on StackOverflow I found a post that said specifying the spec directory fixed some bug for him. But then, I realized just now that this means I'm probably specifying the path twice so one of them is not being used, so I changed it to remove spec from the command line like so:
and it works as expected! So, is the bug just that the default failed_mode is set incorrectly somehow, perhaps when you specify a custom cmd? It didn't do this when I didn't specify the cmd to use spring. I'll try removing both options and see what happens. Somehow it's a lot slower with the debug option when running without spring. Thank you for helping me out! I just didn't know where to look but your guidance was enough to help me figure this out. |
Hmm, now I'm confused, when I removed the cmd option (i.e. not using spring) I still see
But I swear it worked normally one time when I was not using spring. Oh well, I guess the important part is that I know to change failed_mode to :none. |
Ah, looks like 4.2.10 does not include 802edda That explains a lot! |
@ibrahima Yes, it's not released yet =\ |
I'm closing this, because it seems outdated (given the releases that happened since). If not, please open a new issue if need. |
I'm not sure if this is a guard-rspec issue, a spring issue, or a guard issue, but I've got a (private) Rails 3 project that I'm using Spring and Rspec3 with (well, I upgraded to these in an effort to modernize the project a bit and eventually move to Rails 4). When I use the default Guardfile it works fine without Spring, but when I use spring like
guard :rspec, all_after_pass: false, cmd: 'spring rspec spec -f doc' do
and then edit a file, it doesn't re-run the specs that are relevant to that file, it instead runs a fixed subset of unrelated specs every time I modify files. This defeats the purpose of Spring, needless to say. Any ideas on how I can figure out what's going on or try to fix it? It seems like if this happened to everyone no one would use spring with guard-rspec but it seems like it works for some people. Apologies if this is not the proper place for this kind of issue.
Relevant gem versions:
guard-rspec (4.2.10)
rspec 3.0.0
rspec-core 3.0.2
rspec-rails 3.0.1
guard 2.6.1
Platform is Linux 3.13 on Ubuntu 14.04.
The text was updated successfully, but these errors were encountered: