Lievcin
Lievcin

Reputation: 938

Ruby debugging and console

can anyone suggest a nice (not Netbeans) platform where i would be able to write ruby code to test?

I find irb a bit hard to follow when you want to define a method more than 3 lines long, and then test it.

Also, maybe just as a wish list item, some way where I could do follow the code step by step to monitor values in variables and make sure things are being done properly? I'm asking because so far I've been writing in rails, but what you see is the final result of the method, and if you already expected a certain answer, then is fine, but if I need a more complicated method, i would like to be able to follow all the steps to make sure is doing what I want it to do.

Thanks a lot!

Upvotes: 0

Views: 461

Answers (2)

Diane Van Etten
Diane Van Etten

Reputation: 16

I know you said you find irb a bit hard to follow when you want to define a method more than 3 lines long, but if you use irb -rn ./(your file name here), you will get an irb output of every class, method, module, etc.

irb will walk through line by line so you can see what is working and what is not (you'll get true, false, nil, etc) for each line of code. I've found that you can skip what you already know is working and move on to where you feel the issues are.

Upvotes: 0

Kalendae
Kalendae

Reputation: 2244

a great ide is rubymines by intellij. it is not free though. you can step through code and have the usual ide debugging features.

otherwise if the only problem you have is that you are examining code that is more than 3 lines, you can install the ruby-debug gem and then put the keyword debugger in your code and it will cause a break. So you don't need to put code into irb, just run your ruby script and it will break.

Upvotes: 1

Related Questions