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 <dan.bikle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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 = "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 = "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
> => 1 require File.dirname(__FILE__) +
''/../test_helper''
> 2
> 3 class BikleTest < Test::Unit::TestCase
> 4 def setup
> 5 @string10 = "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/active_support/dependencies.rb:213:in
> `require''
> from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:182:in
`activate''
> 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
`activate''
> from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:167:in
`activate''
> 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
`activate''
> 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
> /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 = 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
>