How to debug ruby tests in Eclipse/Aptana Studio? - ruby-on-rails

is there a way to debug all/single tests in Aptana Studio / Eclipse?
ruby-debug19 & ruby-debug-ide are installed and I'm able to set breakpoints and debug my development environment, e.g. in a controller's index method. If I go to http://localhost:3000/controler_name eclipse opens debugging perspective and halts.
But how to do that with tests / rspec tests?
Thanks in advance.

For a normal ruby file, right click on it and select Debug As > Ruby application.
If your test is a rails one that requires some setup, or you want to debug the whole suite, you'll need to generate a debug configuration manually (or edit one manually).
Run > Debug As > Debug configurations... Then add an entry under Ruby application. Point it at your rake script path (say /usr/local/bin/rake) as the file to launch and then edit the arguments to pass in your app's Rakefile as the first arg and the rake task as the second arg. (i.e. /my/path/to/project/Rakefile tests)

Related

Can't turn off debugger in rails

I wanted to debug a test (MiniTest) in my Rails app. Therefore I followed the instruction on the Minitest-Debugger Github Page. Here is the important snippet:
Add this to the top of your test file or helper:
require 'minitest/debugger' if ENV['DEBUG']
Then run your tests as normal but define DEBUG=1:
% DEBUG=1 rake test
Debug.rb
Emacs support available.
Since then, all rails commands (like rails server or bundle exec rake test) I type into the console from my app directory try to start the debugger, which doesn't even work right but gives me some error messages from classes / parts outside my app.
% rails s
Debug.rb
Emacs support available.
/Users/chris/.rvm/gems/ruby-2.0.0-p353/gems/binding_of_caller-0.7.2/lib/binding_of_caller/mri2.rb:25: `' (NilClass)
How can I reset my environment / Rails / Ruby so it runs normally. I tried of course:
% DEBUG=0 rails s
But that didn't change anything. I deleted everything I set up in order to debug.
What do I have to do to stop Rails from entering debug-mode?

How To:Debugging Rails 3.1.x app(Ruby 1.9.3) on Aptana Studio3 in Ubuntu

Is rails debugging supported on Aptana Studio 3. I have earlier debugged Rails applications on Aptana Studio2 with the embedded browser and embedded servers.
1)How to start rails application in Debug Mode?
2)How to enable remote debugging in firefox?
My work environment is as follows and I have been using RVM
Rails 3.1.x
Ruby 1.9.3
Ubuntu 10.10
I have already installed the debug related gems
ruby-debug-base19 (0.11.25)
ruby-debug-ide19 (0.4.12)
Try removing (commenting out) ruby-debug-base19 from Gemfile. "ruby-debug-ide" should be enough, judging from the comments from a post on different IDE - RubyMine.
For debugging, right click on the project and select "Server Debug", then open the site manually in firefox (you will see the address/port the server listening to in the console). I did not manage to set a breakpoint this way, but I only had a test project with no logic in it, so I am not sure how well it works on a real project.
Not sure about your question on "remote debugging with Firefox".
Answer for Q1: Aptana is just an IDE which provides you a not bad interface to input code. I don't think it a very good idea to 'DEBUG' in it.
For me, debugging rails depends on : command line, unit tets and log files. you should first of all, write an failed unit test, then run it in the command line, and write the implementation code, then run unit test, then write implementation code ... sometimes you need to check the output/log file, finally , the unit tests bar turns to green and your code is implemented.
hope this post useful to you:
How to configure aptana for instant running of my script
Answer for Q2: I don't know your "remote debugging in firefox". If you want to show detailed error message to someone else, just start your server as "development" mode. e.g.
rails s -p 3000 -e development
or just:
rails s

How does one run Rake tasks from Eclipse (using the Aptana RadRails plugin)?

As an XEmacs user, I'm a firm believer that if you're using a powerful editor / IDE, you should attempt to do as many of your development tasks as possible without leaving the environment (e.g. why M-Tab into bash to run make clean when you can just M-! make clean <RET>?).
Given this, how can I run Rake tasks from within Eclipse, using the Aptana Studio / RadRails plugin? I'd like to be able to run, e.g. rake db:migrate and rake db:test:prepare.
Update 2: The easiest way to do it is to right-click on your Ruby project in the Project Explorer pane, then select Rake > your task name (e.g. Rake > db > migrate).
Update 1: Thanks to Shadwell's answer, here's how I did it:
Opened Ruby perspective
Clicked on Window menu and selected Show View > Rake Tasks
In the Rake Tasks tab which appeared, clicked on the Tasks dropbox and selected a task (e.g. db:migrate)
Clicked the green run button to the right of the Tasks / Parameters line
There's actually a rake tasks view provided by the aptana plugin which allows you to run rake tasks.
You can also run rake tasks from a 'rails shell'. I open this from the "open shell" menu on the console view but I'm sure there's a better way to do it.
Just a note that in Studio 3, there's an embedded Terminal view that you'd use to do the equivalent inside the IDE now. It is just like using the command line outside the IDE, and on Windows is typically a cygwin/msys shell setup.

Rails console in Netbeans

Netbeans ide has rails console? I use Netbeans for PHP for a long time, and now I want use to my Rails applications. I saw the generators, bundle has a fast gui menu, but can I use this commands myself in Netbeans, so I looking a built in console.
right-click on the project in ur Project window, u will see a selection called "Rails Console"
-edit-
if you want shell, terminal. you might have to launch it will cmd, ssh or whatever way to access it.
--edit 2--
you might can check this out:
http://wiki.netbeans.org/FaqRubyTerminalEmulator

How to run the rails console in debug mode in Aptana Radrails

In Apatana Rad Rails, I want to run the rails console in debug mode. When I launch the debugger as shown below, debugger doesn't honor the break points.
debug script/console
I am able to run the rake tasks in debug mode by giving a similar command, i.e.
debug rake db:migrate
Any pointers will be highly appreciated.
Seems like you're running RadRails 2. You might be able to get it to work correctly by right-clicking the script/console file and choosing Debug As > Ruby Application. The "Rails console" had some special hacks and contortions to handle commands like "debug rake ...", but under the hood it's doing the same as the Debug As action above and then tying the input/output to the console view.

Resources