alexgb / guard-konacha

Automatically run konacha tests through Guard
MIT License
31 stars 17 forks source link

spec not running through guard #25

Closed brewster1134 closed 10 years ago

brewster1134 commented 10 years ago

I just installed guard-konacha and realized my specs were returning 0 tests passed. When i run them manually, they pass.

through guard w/ debug

22:09:48 - DEBUG - Trying to run Guard::Konacha#run_on_modifications with ["foo_spec.coffee"]
22:09:48 - DEBUG - Hook :run_on_changes_begin executed for Guard::Konacha

22:09:48 - DEBUG - Hook :run_on_changes_end executed for Guard::Konacha
22:09:48 - DEBUG - Command execution: stty -g 2>/dev/null
22:09:48 - DEBUG - Start interactor

with konacha...

➜  project git:(master) ✗ rake konacha:run SPEC=foo_spec.coffee
F

  Failed: accordion should have tests!
    AssertionError: expected false to be true

Finished in 0.00 seconds
1 examples, 1 failed, 0 pending
➜  project git:(master) ✗

Also, when i hit enter in guard, it runs ALL the tests ok as well.

Do i have to configure something else?

alexgb commented 10 years ago

What does your Guardfile look like?

brewster1134 commented 10 years ago
### Guard::Konacha
#  available options:
#  - :run_all_on_start, defaults to true
#  - :notification, defaults to true
#  - :rails_environment_file, location of rails environment file,
#    should be able to find it automatically
guard :konacha, run_all_on_start: false do
  watch(%r{^app/assets/javascripts/release/(.*).(?:js|coffee)$}) { |m| "#{m[1]}_spec" }
  watch(%r{^app/views/home/assets/demos/_(.*).haml$}) { |m| "#{m[1]}_spec" }
  watch(%r{^spec/javascripts/*.coffee$})
end

guard :rake, :run_on_start => false, :task => 'release:js' do
  watch(%r{^app/assets/javascripts/release/(.*).(?:js|coffee)$})
end

guard :rake, :run_on_start => false, :task => 'release:css' do
  watch(%r{^app/assets/stylesheets/internal/_(.*).(?:scss|sass)$})
  watch(%r{^app/assets/stylesheets/release/_(.*).(?:scss|sass)$})
end
alexgb commented 10 years ago

I think your regular expressions is off, %r{^spec/javascripts/*.coffee$} doesn't match foo_spec.coffee.

First, you should name your coffeescript files according to the asset pipeline convention of .js.coffee, then use watch(%r{^spec/javascripts/.+_spec(\.js|\.js\.coffee)$}) to match files in your spec directory.

brewster1134 commented 10 years ago

i have made the suggested updates, but still have the same issue....

guard :konacha, run_all_on_start: false do
  watch(%r{^app/assets/javascripts/release/(.*).(js|js.coffee)$}) { |m| "#{m[1]}_spec" }
  watch(%r{^spec/javascripts/.*.(?:js|coffee)$})
end

making changes to foo.js.coffee outputs...

12:00:07 - DEBUG - Trying to run Guard::Konacha#run_on_modifications with ["foo_spec"]
12:00:07 - DEBUG - Hook :run_on_changes_begin executed for Guard::Konacha

12:00:08 - DEBUG - Hook :run_on_changes_end executed for Guard::Konacha
12:00:08 - DEBUG - Command execution: stty -g 2>/dev/null
12:00:08 - DEBUG - Start interactor

however if i hit enter from guard to run all the tests, they run, or if i run from the cli, it works as well.

brewster1134 commented 10 years ago

i made a test app to show this behavior here on the konacha_25 branch

with guard running, and modifications are made to foo.js.coffee, the results of the spec are not shown. if you change foo_spec.js.coffee, or hit enter from guard, the results are shown.

alexgb commented 10 years ago

Awesome, that will be super helpful. I'll take a look soon.

alexgb commented 10 years ago

Your issues should be addressed in this PR https://github.com/brewster1134/test/pull/2. Reopen if your still having problems.