guard / guard-rspec

Guard::RSpec automatically run your specs (much like autotest)

Home Page:https://rubygems.org/gems/guard-rspec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmd: "spring rspec", failed_mode: :foucs doesn't re-run failed specs

tehfailsafe opened this issue · comments

commented

Recently created a new rails 4.1.1 app and the failed_mode doesn't seem to re-run fails. Instead it just reruns all the specs.

Default guard file with cmd: "spring rspec" added:
guard :rspec, cmd: "spring rspec", failed_mode: :focus 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|.slim)$}) { |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 features specs

watch(%r{^app/views/(.+)/.*.(erb|haml|slim)$}) { |m| "spec/features/#{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

Paste from hitting enter in terminal twice:
[1] guard(main)>
18:45:12 - INFO - Run all
18:45:12 - INFO - Running all specs
...........F....

Failures:

  1. Manage subscriptions create a new subscription

removed lots of gibberish from the failure

Finished in 1.33 seconds (files took 21 minutes 42 seconds to load)
16 examples, 1 failure

Failed examples:

rspec ./spec/requests/manage_subscriptions_spec.rb:12 # Manage subscriptions create a new subscription

Randomized with seed 10737

[2] guard(main)>
18:45:15 - INFO - Run all
18:45:15 - INFO - Running all specs

etc.

My assumption was that failed_mode: :focus would re-run only the failed test on the next run, but it just runs all again. Is something missing?

Having a similiar/same problem. First run runs specs for the changed file. Second run runs nothing. Was working right before I upgraded to rspec 3, most likely related to that.

Here's an example output

16:15:20 - INFO - Running: spec/models/example_spec.rb
F............................................................

Finished in 30.71 seconds
61 examples, 1 failure

[1] guard(main)>

16:16:35 - INFO - Running:
No examples found.


Finished in 0.00035 seconds
0 examples, 0 failures

@tehfailsafe @DexterTheDragon Thanks for reporting. Could you please provide a sample application reproducing the error?

It's looking like the problem is in Guard::Rspec::Formatter. When I run the specs against RSpec 3 I get the following failure.

Failures:

  1) Guard::RSpec::Formatter#write_summary without stubbed IO creates temporary file and and writes to it
     Failure/Error: expect(File).to receive(:open).with(temporary_file_path, 'w') { |filename, mode, &block| block.call writer }
     NameError:
       undefined local variable or method `examples' for #<Guard::RSpec::Formatter:0x00000004ad9fe0>
     # ./lib/guard/rspec/formatter.rb:77:in `_failed_paths'
     # ./lib/guard/rspec/formatter.rb:65:in `block in write_summary'
     # ./spec/lib/guard/rspec/formatter_spec.rb:37:in `call'
     # ./spec/lib/guard/rspec/formatter_spec.rb:37:in `block (5 levels) in <top (required)>'
     # ./lib/guard/rspec/formatter.rb:73:in `_write'
     # ./lib/guard/rspec/formatter.rb:63:in `write_summary'
     # ./spec/lib/guard/rspec/formatter_spec.rb:38:in `block (4 levels) in <top (required)>'

@DexterTheDragon Thanks for reporting! I just released v4.2.10 with fix for RSpec 3.0.0, please try it.
cc @tehfailsafe

Works for me. Thanks!

commented

Perfect, it's now focused on the failure.

commented

Closing.