Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

debugger statements not triggering the debugger in rails 3.0.4

#6419

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.

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

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Ross Heflin
  2. Wojciech Wnętrzak
    Wojciech Wnętrzak

    Try to change line in your Gemfile containing ruby-debug19:

     gem "ruby-debug19", :require => "ruby-debug"
    

    February 12th, 2011 @ 11:55 AM

  3. Wojciech Wnętrzak
    Wojciech Wnętrzak

    I just checked, and on rails master, Gemfile is generated with this example, but without proper require.
    I'm adding a patch with working example of ruby-debug19 gem.

    February 12th, 2011 @ 12:36 PM

  4. Repository
    Repository
    • State changed from new to committed

    (from [22e14ea5739f552dfc663f563835fa27669d627d]) added proper require for ruby-debug19 gem to generated Gemfile

    [#6419 state:committed]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/22e14ea5739f552dfc663f563835f...

    February 13th, 2011 @ 12:41 AM

  5. Repository
    Repository

    (from [9c6f9c98b84827a55eba203c89611b7d9afd3cde]) added proper require for ruby-debug19 gem to generated Gemfile

    [#6419 state:committed]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/9c6f9c98b84827a55eba203c89611...

    February 13th, 2011 @ 12:46 AM