This project is archived and is in readonly mode.

#6419 ✓committed
Ross Heflin

debugger statements not triggering the debugger in rails 3.0.4

Reported by Ross Heflin | February 12th, 2011 @ 01:41 AM

Summary:

Updated a rails app from 3.0.3 to 3.0.4 today
and discovered I could no longer hit breakpoints set within tests.
Attached, you'll find a simple project which duplicates this behavior.

I'm not sure if this is particularly a regression in rails,
but I don't see this behavior when using rails 3.0.3 with this project

To Reproduce the Issue:

Blow out the attached tarball and cd into the foo directory, run the following commands:

rake db:reset
bundle install
rake test

Expected Behavior:

A debugger statement w/in the FooTest should be hit and opened in rdb with output like the following:

rheflin@elitethis:~/src/foo$ rake test
(in /home/rheflin/src/bs)
Loaded suite /home/rheflin/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
[2, 11] in test/unit/foo_test.rb
   2  
   3  class FooTest < ActiveSupport::TestCase
   4    # Replace this with your real tests.
   5    test "the truth" do
   6      debugger
=> 7      assert false
   8    end
   9  end
test/unit/foo_test.rb:7
assert false
(rdb:1)

Actual Behavior:

What actually happens is the breakpoint gets skipped and the test fails.

rheflin@elitethis:~/src/foo$ rake test
(in /home/rheflin/src/foo)
Loaded suite /home/rheflin/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
F
Finished in 0.265451 seconds.

  1) Failure:
test_the_truth(FooTest) [test/unit/foo_test.rb:7]:
Failed assertion, no message given.

1 tests, 1 assertions, 1 failures, 0 errors, 0 skips

Test run options: --seed 36151
Errors running test:units!
rheflin@elitethis:~/src/foo$

Workaround

To get the breakpoint to trigger (as it did in 3.0.3) explicitly add require 'ruby-debug' to the test/test_helper.rb file so its contents match the following:

--- modified test/test_helper.rb

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'ruby-debug'

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
  #
  # Note: You'll currently still have to declare fixtures explicitly in integration tests
  # -- they do not yet inherit this setting
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

Then the breakpoint will be hit and you should drop into the debugger:

rheflin@elitethis:~/src/foo$ rake test
(in /home/rheflin/src/bs)
Loaded suite /home/rheflin/.rvm/gems/ruby-1.9.2-p136/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
[2, 11] in test/unit/foo_test.rb
   2  
   3  class FooTest < ActiveSupport::TestCase
   4    # Replace this with your real tests.
   5    test "the truth" do
   6      debugger
=> 7      assert false
   8    end
   9  end
test/unit/foo_test.rb:7
assert false
(rdb:1)

My Environment details (in case they're needed):
OS: Ubuntu Linux 10.10 (maverick)
Arch: x86_64
Ruby: 1.9.2p136 (built by rvm 1.2.6)

I'll be happy to provide more information if needed, let me know.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments