Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » STEPS TO: Setup Ruby Debugging AND Minitest(In these 7 steps you can get ruby working and debuggin in eclipse)
STEPS TO: Setup Ruby Debugging AND Minitest [message #631871] |
Sat, 09 October 2010 12:28 |
|
hi there, I struggled to get the debugger working for my ruby code. As well as unit testing working. I wanted to use ruby 1.9 but it appears the the ide debugger for this version does not work. That's the only reason I've use ruby 1.8.7
I have listed the steps i followed below in case anyone else is struggling. I stick all my development tools in a folder C:\devtools\ ...but you can use what you want.
Quote: |
1. Install rubyinstaller-1.8.7-p302.exe into "C:\devtools\ruby187" from http://rubyinstaller.org/downloads/
(ensure "C:\devtools\Ruby187\bin" is added to PATH)
2. Install DevKit-4.5.0-20100819-1536-sfx.exe from http://rubyinstaller.org/downloads/ into "C:\devtools\RubyDevKit"
(follow instructions http://github.com/oneclick/rubyinstaller/wiki/Development-Ki t)
3. From your command prompt, type: gem install ruby-debug
4. And then: gem install minitest
5. And now type: gem list --local to ensure you have these gems installed:
*** LOCAL GEMS ***
columnize (0.3.1)
linecache (0.43)
minitest (1.7.2)
rake (0.8.7)
rdiscount (1.6.5)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.10)
6. In Eclipse, install software from the DLTK site: http://download.eclipse.org/technology/dltk/updates/
Dynamic Langauges Toolkit - Core Frameworks
Dynamic Langauges Toolkit - Core Frameworks SDK
Dynamic Langauges Toolkit - Ruby Development Tools
Dynamic Langauges Toolkit - Ruby Development Tools SDK
7. Eclipse > Window > Preferences > Ruby > Interpreters > ...add and check C:\devtools\Ruby187\bin\ruby.exe
|
You should be able to write ruby code now as well as run the debugger within Eclipse.
Below is a simple minitest setup should you want to get into unit testing / test driven development:
require 'rubygems'
require 'Roman'
gem 'minitest'
require 'minitest/unit'
MiniTest::Unit.autorun
class TestRoman < MiniTest::Unit::TestCase
def test_simple
assert_equal("i", Roman.new(1).to_s)
assert_equal(5,6)
end
end
Which is testing this class:
# NOTE: This code has bugs!
class Roman
MAX_ROMAN = 4999
def initialize(value)
if value <= 0 || value > MAX_ROMAN
fail "Roman values must be > 0 and <= #{MAX_ROMAN}"
end
@value = value
end
FACTORS = [["m", 1000], ["cm", 900], ["d", 500], ["cd", 400],
["c", 100], ["xc", 90], ["l", 50], ["xl", 40],
["x", 10], ["ix", 9], ["v", 5], ["iv", 4],
["i", 1]]
def to_s
value = @value
roman = ""
for code, factor in FACTORS
count, value = value.divmod(factor)
roman << code unless count.zero?
end
roman
end
end
Feel free to add comments / updates / improvements. But the above worked for me.
Cheers, Michelle
[Updated on: Sat, 09 October 2010 12:36] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Wed Sep 25 23:53:09 GMT 2024
Powered by FUDForum. Page generated in 0.04215 seconds
|