remote debugging cucumber step definitions

Is this possible? If so, how?

I have gotten the remote debugger working for a simple Ruby script by running this command on the server:
rdebug-ide --host 0.0.0.0 --port 1234 -- "C:\tests\my_test.rb"

I was hoping I could do something similar for a cucumber feature and hit breakpoints set in the step definition file.

I tried this:

C:\>rdebug-ide --host 0.0.0.0 --port 1234 -- "C:\tests\my_test.feature"

Debugger appeared to start:
Fast Debugger (ruby-debug-ide 0.4.16, ruby-debug-base 0.10.4) listens on 0.0.0.0:1234

When I connected from the IDE, this was ouput to the command window on the server:
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_load'
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_program'
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/bin/rdebug-ide:87
        C:/Ruby/bin/rdebug-ide:19:in `load'
        C:/Ruby/bin/rdebug-ide:19
Uncaught exception: C:\tests\my_test.feature:1: syntax error, unexpected ':', expecting $end
Feature: This is the first feature in my_test.feature file
            ^



I also tried loading the step definition file:

rdebug-ide --host 0.0.0.0 --port 1234 -- "C:\tests\step_definitions\my_test_steps.rb"



Got this:

Fast Debugger (ruby-debug-ide 0.4.16, ruby-debug-base 0.10.4) listens on 0.0.0.0
:1234
        C:\tests\step_definitions\my_test_steps.rb:54
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_load'
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_program'
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/bin/rdebug-ide:87
        C:/Ruby/bin/rdebug-ide:19:in `load'
        C:/Ruby/bin/rdebug-ide:19
Uncaught exception: undefined method `Then' for main:Object
Loaded suite C:\tests\step_definitions\my_test_steps
Started


Finished in 0.015635 seconds.


0 tests, 0 assertions, 0 failures, 0 errors



I'm out of ideas. Looks like I'm stuck with the command line debugger on the server for now.

Would really appreciate your input on this.

Cheers,
~Alan
4 comments
Comment actions Permalink

C:\>rdebug-ide --host 0.0.0.0 --port 1234 -- "C:\tests\my_test.feature"

Debugger appeared to start:
Fast Debugger (ruby-debug-ide 0.4.16, ruby-debug-base 0.10.4) listens on 0.0.0.0:1234

When I connected from the IDE, this was ouput to the command window on the server:
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_load'
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in `debug_program'
        C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.16/bin/rdebug-ide:87
        C:/Ruby/bin/rdebug-ide:19:in `load'
        C:/Ruby/bin/rdebug-ide:19
Uncaught exception: C:\tests\my_test.feature:1: syntax error, unexpected ':', expecting $end
Feature: This is the first feature in my_test.feature file
            ^

ruby-debug-ide debugs scripts in ruby/erb language. For debugging feature files you need to debug "cucumber" launcher script. But even in such case you can place breakpoints only in ruby step definitions, not in *.feature file, feature file is like a text based config, it just describes step definitions and doesn't invoke them.

0
Comment actions Permalink

Thanks Roman. I understand that I can't debug feature files. I am only interested in debugging the step definitions, but I need the feature file to invoke the methods and pass in any data.

Do you happen to know where this cucumber launcher script is located?
Does it take the feature file as a parameter?

Cheers,
~Alan

0
Comment actions Permalink

Looks like you debug your local host. Why don't you use RubyMine debugger feature?

Do you happen to know where this cucumber launcher script is located?
Does it take the feature file as a parameter?

For rails projects - "./script/cucumber" for pure ruby - in bin folder near to rails, gem, rake etc scripts. You may run/debug any feature file from RubyMine and look at cmdline which RubyMine shows in console output tool window.
Screen shot 2011-04-01 at 9.42.16 PM.png

0
Comment actions Permalink

Sweet! Got it working.

As you suggested, got the first line from the Console output in RM when debugging a feature file and mocked up my own version:
rdebug-ide --host 0.0.0.0 --port 1234 -- C:\Ruby\bin/cucumber C:\tests\my_test.feature --expand --color -r Custom_Pages

I am debugging on a test server and I have RM running on my desktop.

If you assumed that --host 0.0.0.0 meant localhost, that's not actually the case, at least not in Windows.
Actually, this is something you guys should add to the "Ruby remote debug" configuration.

Currently, RM proposes that the following command be run on the server:
rdebug-ide --port 1234 -- $SCRIPT$

This causes the debugger to listen on 127.0.0.1:1234 so that only a localhost debugee can connect.

This is what RM should suggest to run on the debug server:
rdebug-ide --host 0.0.0.0 --port 1234 -- $SCRIPT$



Adding --host 0.0.0.0 allows a remote debugee to connect to the debugger.

Cheers,
~Alan
0

Please sign in to leave a comment.