[cucumber] how to debug cucumber with netbeans?

3 months ago, I submitted a patch to cucumber so I could run cucumber
from a
ruby script and use the debugger in netbeans
(Lighthouse - Beautifully Simple Issue Tracking)

It worked well at the time but I can’t make it work with cucumber 0.3.2.
Here is the stacktrace:
ruby script/cucumber_netbeans_runner.rb
cucumber features/_admin/projects.feature --profile default
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
gem_original_require': no such file to load -- lib/active_merchant (MissingSourceFile) Failed to load ./vendor/plugins/active_merchant/lib/support/gateway_support.rb from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in polyglot_original_require’
from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in
require' from /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in require’
from
/Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:342:in
new_constants_in' from /Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:496:in require’
from ./vendor/plugins/active_merchant/lib/support/gateway_support.rb:3
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in polyglot_original_require’
… 8 levels…
from
/Library/Ruby/Gems/1.8/gems/cucumber-0.3.2/lib/cucumber/cli/main.rb:20:in
execute' from script/cucumber_netbeans_runner.rb:29:in run’
from script/cucumber_netbeans_runner.rb:21:in `run_feature’
from script/cucumber_netbeans_runner.rb:37

And the script:

require ‘rubygems’
require ‘cucumber/cli/main’

module Cucumber
module Netbeans
class Runner
def initialize(cucumber_opts=nil)
@argv = []
@cucumber_opts = cucumber_opts || " --profile default"
end

  def run_scenario(line_number)
    @cucumber_opts << " --line #{line_number}"
    run
  end

  def run_feature(feature)
    @argv << "#{feature}"
    run
  end

  protected

  def run
    @argv << @cucumber_opts
    puts %Q{cucumber #{@argv.join(' ')} \n}
    Cucumber::Cli::Main.execute(@argv)
  end
end

end
end

Cucumber::Netbeans::Runner.new().run_feature
“features/_admin/projects.feature”

I wonder if fellow netbeans on cucumber users will have an idea …
Ironically, debugging that script with netbeans crashes the debugger at
Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54

For the time being, I am using the “old school” ruby-debug which works
pretty well …

JM

View this message in context:
http://www.nabble.com/-cucumber--how-to-debug-cucumber-with-netbeans--tp23446299p23446299.html
Sent from the rspec-users mailing list archive at Nabble.com.

Jean-Michel Garnier wrote:

(MissingSourceFile)
/Users/jeanmichel/Projects/betterplace/trunk/vendor/rails/activerecord/lib/…/…/activesupport/lib/active_support/dependencies.rb:342:in
from

    run
    @argv << @cucumber_opts

I wonder if fellow netbeans on cucumber users will have an idea …
Ironically, debugging that script with netbeans crashes the debugger at
Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54

For the time being, I am using the “old school” ruby-debug which works
pretty well …

JM

So, you can run the feature fine without the debugger? What is
confusing is that “lib/active_merchant” is showing up in the backtrace
saying it can’t be found… What if you try to run the feature with the
debugger from outside of Netbeans? Just trying to get an idea of who
the culprit really is here.

-Ben

Jean-Michel Garnier wrote:

I wonder if fellow netbeans on cucumber users will have an idea …
Ironically, debugging that script with netbeans crashes the debugger at
Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54

For the time being, I am using the “old school” ruby-debug which works
pretty well …

JM

Thanks for your answer, Ben

So, you can run the feature fine without the debugger?

  • yes, it run fine indeed, I mean it loads everything all right and then
    crash in a cucumber step with “segmentation fault”

What is
confusing is that “lib/active_merchant” is showing up in the backtrace
saying it can’t be found…

  • I don’ understand it either and I suspect it’s a Rails / cucumber /
    polyglot rubygems issue as I have found a few messages describing
    problems
    with cucumber and “polyglot_original_require’
    from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54”

  • For the time being, I just give up debugging cucumber with netbeans

What if you try to run the feature with the
debugger from outside of Netbeans?

  • You mean with classic ruby-debug? I had never used it before as I come
    from a java + Eclispe background and always used an IDE to debug.

I must admit that ruby-debug is very easy to use and it did well to find
the
cause of my problem:
cucumber calling webrat visit with “eval”. There was a bug in a
before_filter of a controller which was doing an infinite loop.
Apparently,
the mac ruby interpreter did not like it and crashed with “segmentation
fault”. Running Rails in “development” mode was working fine and showing
an
exception stacktrace…

This is the kind of situtation where TDD is actually slower than
“prehistoric development with no tests”. I spent 3 hours looking for the
source of the problems and it took me 15 minutes running Rails in
developement mode.

In order to improve webrat, I’ll spend 1 hour this morning o try to
write a
spec to reproduce the bug.

View this message in context:
http://www.nabble.com/-cucumber--how-to-debug-cucumber-with-netbeans--tp23446299p23458483.html
Sent from the rspec-users mailing list archive at Nabble.com.

Hi Jean,

2009/5/9 Ben M. [email protected]:

Jean-Michel Garnier wrote:

3 months ago, I submitted a patch to cucumber so I could run cucumber
from
a
ruby script and use the debugger in netbeans

Is it possible for you to Wiki how to use the Netbeans debugger
through Cucumber and your patch?


Aidy
blog: www.agiletester.co.uk
twitter: http://twitter.com/aidy_lewis

aidy_lewis wrote:

Hi Jean,

Is it possible for you to Wiki how to use the Netbeans debugger
through Cucumber and your patch?

Aidy

Aidy, I could not use netbeans because of the gems loading problem as I
said
in my first message.
However, I was successfull with ruby-debug, see

In the meanwhile, I was successful reproducing the bug with a test in
webrat
:
https://webrat.lighthouseapp.com/projects/10503/tickets/243-segmentation-fault-when-visiting-rails-action-with-infinite-loop

A simple fix would be to replace the code generation created with
“eval”. I
believe it might speed up also cucumber as eval is slower than normal
ruby
code …


View this message in context:
http://www.nabble.com/-cucumber--how-to-debug-cucumber-with-netbeans--tp23446299p23497830.html
Sent from the rspec-users mailing list archive at Nabble.com.

Jean-Michel Garnier wrote:

Cucumber::Netbeans::Runner.new().run_feature

I must admit that ruby-debug is very easy to use and it did well to find the
developement mode.

In order to improve webrat, I’ll spend 1 hour this morning o try to write a
spec to reproduce the bug.

Glad you got it fixed. Yeah, TDD/BDD certainly can slow you down at
times especially on initial investments like this. It just comes down
to if it is worth it for you and this project or if you would be fine
with some technical debt. :slight_smile:

-Ben