netzpirat / guard-cucumber

Guard::Cucumber automatically runs your features (much like autotest)
https://rubygems.org/gems/guard-cucumber
MIT License
40 stars 56 forks source link

It doesn't show the errors when :cli option is used #19

Closed restebanez closed 13 years ago

restebanez commented 13 years ago

Hi there,

When i use :cli option (no matter what options i specify), guard hides the cucumber errors and shows a "Done." instead

Guardfile with :cli guard 'cucumber', :change_format => 'pretty', :cli => "--drb"


restebanez@Rodrigo-Estebanez-MacBook-Pro:~/agi [develop] guard
Please install rb-fsevent gem for Mac OSX FSEvents support
Using polling (Please help us to support your system better than that).
Guard is now watching at '/Users/restebanez/agi'
Starting Spork for RSpec & Cucumber 
Using RSpec
Using Cucumber
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
Spork server for RSpec & Cucumber successfully started
Guard::RSpec is running, with RSpec 2!
Run Cucumber features features/app/app.feature
Using the default profile...
Running tests with args ["--require", "/Users/restebanez/.rvm/gems/ruby-1.9.2-p290@agi/gems/guard-cucumber-0.7.2/lib/guard/cucumber/notification_formatter.rb", "--format", "Guard::Cucumber::NotificationFormatter", "--out", "/dev/null", "--require", "features", "features/app/app.feature", "--format", "pretty", "--strict", "--tags", "~@wip", "--no-profile"]...
Disabling profiles...
Feature: Show App page
  As a user
  I want Agi to show me the configuration and status of an app

  Background:           # features/app/app.feature:5
    Given an app exists # features/step_definitions/pickle_steps.rb:4

  Scenario: Show an app that has never been deployed # features/app/app.feature:8
    And I go to the app show page                    # features/step_definitions/web_steps.rb:49
Done.
If i removed the :cli option in my Guardfile, it shows things correctly:

restebanez@Rodrigo-Estebanez-MacBook-Pro:~/agi [develop] guard
Please install rb-fsevent gem for Mac OSX FSEvents support
Using polling (Please help us to support your system better than that).
Guard is now watching at '/Users/restebanez/agi'
Starting Spork for RSpec & Cucumber 
Using RSpec
Using Cucumber
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
Spork server for RSpec & Cucumber successfully started
Guard::RSpec is running, with RSpec 2!
Run Cucumber features features/app/app.feature
Disabling profiles...
Feature: Show App page
  As a user
  I want Agi to show me the configuration and status of an app

  Background:           # features/app/app.feature:5
    Given an app exists # features/step_definitions/pickle_steps.rb:4

  Scenario: Show an app that has never been deployed # features/app/app.feature:8
    And I go to the app show page                    # features/step_definitions/web_steps.rb:49
      Could not figure out a path for ["the app"] {:extra=>"show"} (RuntimeError)
      ./features/support/paths.rb:41:in `path_to'
      ./features/step_definitions/web_steps.rb:50:in`/^(?:|I )go to (.+)$/'
      features/app/app.feature:9:in `And I go to the app show page'
    Then I should see "Undeployed changes" alert     # features/app/app.feature:10
      Undefined step: "I should see "Undeployed changes" alert" (Cucumber::Undefined)
      features/app/app.feature:10:in`Then I should see "Undeployed changes" alert'

Failing Scenarios:
cucumber features/app/app.feature:8 # Scenario: Show an app that has never been deployed

1 scenario (1 failed)
3 steps (1 failed, 1 undefined, 1 passed)
0m1.453s

You can implement step definitions for undefined steps with these snippets:

Then /^I should see "([^"]*)" alert$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end
Thanks!
netzpirat commented 13 years ago

When you remove the :cli option from your guard, then the default :cli option is used:

:cli => '--no-profile --color --format progress --strict'

which seems to be fine. Try appending your :cli option to it:

:cli => '--no-profile --color --format progress --strict --drb'

Another user had to explicit add another require to get it running, but other didn't:

:cli => '--no-profile --color --format progress --strict --drb --require features/'
restebanez commented 13 years ago

Thanks Netzpirat!

The first option works fine but the last two still hide the error part, unfortunately i have to use --drb because i use fork.

Thanks

netzpirat commented 13 years ago

I don't have an active project with Cucumber, so I'm unable to play with configuration settings. Please have a look at https://github.com/netzpirat/guard-cucumber/blob/master/lib/guard/cucumber/runner.rb#L38, there you see how the Cucumber command is composed.

I'd try first to get it up and running just from the console without any guard-cucumber specific settings, so that you get your optimal :cli settings. This would cover lines https://github.com/netzpirat/guard-cucumber/blob/master/lib/guard/cucumber/runner.rb#L40-44 and is completely independent from the Guard.

If you don't want to have Growl notifications, your done now (just disable this part by setting :notifications to false). If you want to have these too, you'll have to bring the guard-cucumber formatter into play: https://github.com/netzpirat/guard-cucumber/blob/master/lib/guard/cucumber/runner.rb#L48-51. These settings are for a custom formatter that is responsible for showing the notification. Perhaps something in a newer Cucumber version has changed and some of the options aren't necessary anymore (like --out or --require). Again, this can be done from the command line without having Guard running.

Hope this helps.

restebanez commented 13 years ago

This is getting more interesting, when i disabled notifications (:notification => false), it showed me the errors but pickle steps turned into Undefined, if you enable back notifications, that step passes.

I'll look into the source code when i get a chance.

You can test this behavior clonning my public repo: https://github.com/jbz/agi/tree/develop

netzpirat commented 13 years ago

I have cloned your repository, ran bundler, executed the db:migrate task and changed the :cli option from guard-cucumber to

:cli => '--drb --no-profile --color --format progress --strict'

In addition I have removed the growl and the growl_notify gem from the Gemfile (you just need one Growl library) and added Guard master branch and the ruby_gntp gem:

gem 'guard', :git => 'git://github.com/guard/guard.git'
gem 'ruby_gntp'

This was necessary for me because I have Growl 1.3 on my Mac, so the growl gem is not compatible with it. Also the other growl library growl_notify doesn't run on my machine, it always segfaults. So I have to use ruby_gntp that has not been released officially, thus the need for installing Guard from master branch.

I started Guard and began to modify the features to see how it behaves. I cannot see any unexpected behavior, it runs fine over Spork and shows me the spec runner output (failing, success and pending) and the Growl notification.

restebanez commented 13 years ago

The problem was with 'growl_notify' gem, as soon as i tooked it out of the Gemfile i could see the cucumber error detail. I couldn't use ruby_gntp in my Snow Leopard machine but growl gem works fine. My test group looks like this:


group :test do
  gem 'database_cleaner'
  gem 'rails3-generators' #mainly for factory_girl & simple_form at this point
  gem 'rspec-rails'
  gem 'factory_girl_rails'  # mocking
  gem 'cucumber-rails'
  gem "pickle"          # gives you a lot of already defined cucumber steps
  gem 'capybara'
  gem 'guard' 
  #gem 'growl_notify' # if used, guard doesn't show the errors
  gem 'growl'       # guard uses to notify
  gem 'guard-cucumber'
  gem 'rb-fsevent'      # required by guard for notifications
  gem "guard-rspec"     # run rspec when a spec is saved
  gem "launchy"         # show the web page in case of error
  gem "spork", "> 0.9.0.rc" # Improve loading times during testing
  gem "guard-spork"
end
Thanks a lot!
netzpirat commented 13 years ago

Cool! Thanks for letting me now that is was a problem with growl_notify.