Home > Programming Languages, RoR, Software > Fun with Ruby: The RubyGem Package Manager and the Test-Unit Gem

Fun with Ruby: The RubyGem Package Manager and the Test-Unit Gem

February 2nd, 2009

Ruby is consistently placed as one of the ten most popular programming languages – see the TIOBE Programming Community Index for more language comparisons. Matz (the creator of Ruby) described his guiding philosophy for the language as one that’s “designed to make programmers happy”. While the Ruby language gets a lot of praise for its zen like qualities, its clarity, and terseness. The tools surrounding Ruby like the RubyGem Package Manager along with its active community and growing collection of Gems (view the list here) are often overlooked.

I like the RubyGem system just as much as Ruby, it makes a developer’s life easy.

For example, let’s say I want to design a new class:

  • Install Ruby
  • Install the Test-Unit Gem (along with a couple automatically installed prerequisites):
C:\>gem install test-unit
 Successfully installed test-unit-2.0.2
 Successfully installed hoe-1.8.3
 Successfully installed rubyforge-1.0.2
 Successfully installed rake-0.8.3
  • Create a new test.rb file along with a new class.rb file (alternately we could have used the Interactive Ruby Shell directly from the command line)
  • Run the test (test.rb):
C:\>ruby test.rb
 Loaded suite test
 Finished in 0.001 seconds.
 1 tests, 1 assertions, 1 failures, 0 errors
  • ???
  • Profit! :)

Contrasting this to the Java / C# world: I’d be installing a compiler (or slower yet an IDE), then installing / configuring a testing framework. I’d also probably be installing a build process tool (like ant / nAnt), then I’d need to create a build file.

Similarly if I wanted to install Rails at the command line I specify gem install rails or if I want to useĀ  RSpec gem install rspec.

The Ruby tools, ecosystem, and community is fantastic.

Author: Adam Kahtava Categories: Programming Languages, RoR, Software Tags:
  1. No comments yet.
  1. No trackbacks yet.