[rails] attaching the debugger to functional test.

Discussion in 'Ruby' started by Dan Bikle, Oct 30, 2005.

  1. Dan Bikle

    Dan Bikle Guest

    People,

    I'm trying to run the ruby debugger against a Test::Unit::TestCase class
    which is a parent of a Rails class.

    I started my study with a simple script:

    #
    # bikle_test.rb
    #
    require 'test/unit'

    class BikleTest < Test::Unit::TestCase
    def setup
    @string10 =3D "hello"
    end
    def test10
    assert_equal @string10, "hello"
    end
    end


    The following command line works great:

    ruby -r debug bikle_test.rb


    Next, I create a new rails application with this command line:

    rails rtest

    Then, I create a database.yml:

    test:
    adapter: sqlite3
    dbfile: db/rtest.db

    Then I copied bikle_test.rb to...

    rtest/test/functional/

    I altered it a bit so it behaves like a typical Rails test:


    #
    # bikle_test.rb
    #
    require File.dirname(__FILE__) + '/../test_helper'

    class BikleTest < Test::Unit::TestCase
    def setup
    @string10 =3D "hello"
    end
    def test10
    assert_equal @string10, "hello"
    end
    end


    When I run it, I see this:

    zmac11:/cd/railsdemos/rtest/test/functional oracle$
    zmac11:/cd/railsdemos/rtest/test/functional oracle$
    zmac11:/cd/railsdemos/rtest/test/functional oracle$
    zmac11:/cd/railsdemos/rtest/test/functional oracle$
    zmac11:/cd/railsdemos/rtest/test/functional oracle$ ls
    /=09=09../=09=09bikle_test.rb
    zmac11:/cd/railsdemos/rtest/test/functional oracle$ ruby b*
    Loaded suite bikle_test
    Started
    Dan Bikle, Oct 30, 2005
    #1
    1. Advertising

  2. Dan Bikle

    Eric Hodel Guest

    On Oct 30, 2005, at 11:24 AM, Dan Bikle wrote:

    > People,
    >
    > I'm trying to run the ruby debugger against a Test::Unit::TestCase
    > class
    > which is a parent of a Rails class.


    For Rails questions you'll get the best and fastest answers from the
    Rails mailing list:

    http://lists.rubyonrails.org/mailman/listinfo/rails

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Oct 30, 2005
    #2
    1. Advertising

  3. Dan Bikle

    Dan Bikle Guest

    People,

    I got a good tip from the yahoo ba-rb group on this subject.

    The tip is to...
    'Ignore the error and just press c to continue'

    the tip worked for me.

    -Dan


    On 10/30/05, Dan Bikle <> wrote:
    > People,
    >
    > I'm trying to run the ruby debugger against a Test::Unit::TestCase class
    > which is a parent of a Rails class.
    >
    > I started my study with a simple script:
    >
    > #
    > # bikle_test.rb
    > #
    > require 'test/unit'
    >
    > class BikleTest < Test::Unit::TestCase
    > def setup
    > @string10 =3D "hello"
    > end
    > def test10
    > assert_equal @string10, "hello"
    > end
    > end
    >
    >
    > The following command line works great:
    >
    > ruby -r debug bikle_test.rb
    >
    >
    > Next, I create a new rails application with this command line:
    >
    > rails rtest
    >
    > Then, I create a database.yml:
    >
    > test:
    > adapter: sqlite3
    > dbfile: db/rtest.db
    >
    > Then I copied bikle_test.rb to...
    >
    > rtest/test/functional/
    >
    > I altered it a bit so it behaves like a typical Rails test:
    >
    >
    > #
    > # bikle_test.rb
    > #
    > require File.dirname(__FILE__) + '/../test_helper'
    >
    > class BikleTest < Test::Unit::TestCase
    > def setup
    > @string10 =3D "hello"
    > end
    > def test10
    > assert_equal @string10, "hello"
    > end
    > end
    >
    >
    > When I run it, I see this:
    >
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$ ls
    > ./ ../ bikle_test.rb
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$ ruby b*
    > Loaded suite bikle_test
    > Started
    > .
    > Finished in 0.131351 seconds.
    >
    > 1 tests, 1 assertions, 0 failures, 0 errors
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    >
    >
    > When I try to run it in the debugger I see this:
    >
    >
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$ ruby -r debug b*
    > Debug.rb
    > Emacs support available.
    >
    > bikle_test.rb:1:
    > (rdb:1) l
    > [-4, 5] in bikle_test.rb
    > =3D> 1 require File.dirname(__FILE__) + '/../test_helper'
    > 2
    > 3 class BikleTest < Test::Unit::TestCase
    > 4 def setup
    > 5 @string10 =3D "hello"
    > 6 end
    > 7 def test10
    > 8 assert_equal @string10, "hello"
    > 9 end
    > 10 end
    > 11
    > 12
    > (rdb:1) b 5
    > Set breakpoint 1 at bikle_test.rb:5
    > (rdb:1) c
    > /opt/local/lib/ruby/1.8/drb/drb.rb:1572: `DRb::DRbServerNotFound'
    > (DRb::DRbServerNotFound)
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.=

    rb:21:in
    > `require'
    > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.2.1/lib/ac=

    tive_support/dependencies.rb:213:in
    > `require'
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:182:in `acti=

    vate'
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:181:in `each=

    '
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:181:in `acti=

    vate'
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:167:in `acti=

    vate'
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:166:in `each=

    '
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:166:in `acti=

    vate'
    > from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.=

    rb:26:in
    > `require'
    > from /Users/oracle/CD/railsdemos/rtest/config/boot.rb:14
    > from /Users/oracle/CD/railsdemos/rtest/config/environment.rb:8:in=

    `require'
    > from /Users/oracle/CD/railsdemos/rtest/config/environment.rb:8
    > from ./../test_helper.rb:2:in `require'
    > from ./../test_helper.rb:2
    > from bikle_test.rb:1:in `require'
    > from bikle_test.rb:1
    > =1A=1A/opt/local/lib/ruby/1.8/drb/drb.rb:1572:
    > (rdb:1) q
    > Really quit? (y/n) y
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    > zmac11:/cd/railsdemos/rtest/test/functional oracle$
    >
    >
    > So, it's telling me that it is looking for a DRb Server.
    >
    > Question 1:
    > Why does it need to talk with a DRb Server?
    >
    > Outside of Rails... it does not need to talk with a DRb Server.
    >
    > Question 2:
    > How do I start a DRb Server which would make the debugger happy?
    >
    > I looked in the DT-PickAxe book and found this:
    >
    > # Sample code from Programing Ruby, page 399
    > require 'drb'
    >
    > class TestServer
    > def add(*args)
    > args.inject {|n,v| n + v}
    > end
    > end
    >
    > server =3D TestServer.new
    > DRb.start_service('druby://localhost:9000', server)
    > DRb.thread.join # Don't exit just yet!
    >
    >
    > So, it looks like I give the server a port to listen on
    > which would be easy enough.
    >
    > But, how do I then tell the debugger what that port is?
    >
    > Can any of you offer any insight, solutions, or ideas to experiment with?
    >
    > Thanks,
    >
    > -Dan
    >
    Dan Bikle, Nov 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    1
    Views:
    576
    Jim Cheshire [MSFT]
    Aug 5, 2003
  2. Jim Heavey

    Attaching Debugger

    Jim Heavey, Apr 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    311
    Jim Heavey
    Apr 27, 2004
  3. Andy Leszczynski
    Replies:
    1
    Views:
    456
    SPE - Stani's Python Editor
    Dec 13, 2005
  4. alf
    Replies:
    4
    Views:
    453
    Nebur
    Jul 15, 2006
  5. Andrew Taranov

    Problem attaching script debugger to ASP under IIS6

    Andrew Taranov, Jun 23, 2005, in forum: ASP General
    Replies:
    2
    Views:
    184
    [MSFT]
    Jun 24, 2005
Loading...

Share This Page