Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [rails] attaching the debugger to functional test.

Reply
Thread Tools

[rails] attaching the debugger to functional test.

 
 
Dan Bikle
Guest
Posts: n/a
 
      10-30-2005
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
 
Reply With Quote
 
 
 
 
Eric Hodel
Guest
Posts: n/a
 
      10-30-2005
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://www.velocityreviews.com/forums/(E-Mail Removed) - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04




 
Reply With Quote
 
 
 
 
Dan Bikle
Guest
Posts: n/a
 
      11-14-2005
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 <(E-Mail Removed)> 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:RbServerNotFound'
> (DRb:RbServerNotFound)
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
attaching debugger to runinng python program alf Python 4 07-15-2006 09:03 AM
attaching to running python program with the debugger? Andy Leszczynski Python 1 12-13-2005 11:14 PM
Problem attaching script debugger to ASP under IIS6 Andrew Taranov ASP General 2 06-24-2005 02:05 AM
Attaching Debugger Jim Heavey ASP .Net 0 04-27-2004 03:45 AM
debugger not automatically attaching aspnet_wp.exe as a debugged process Mark Kamoski ASP .Net 1 08-05-2003 02:57 PM



Advertisments