JRuby << RSpec

Posted by aslak.hellesoy

The JRuby team announced at RailsConf 2007 that they will bundle RSpec with JRuby when it goes 1.0. JRuby will only ship with two gems (Rake and RSpec), so I’m extremely proud of being a developer of one of the lucky two, because JRuby is going to be big.

RSpec on JRuby means that the wonders of RSpec will soon be available for Java app developers (as well as JRuby/JRuby on Rails developers), so you can do things like this:


describe Bowling do
  before(:each) do
    @bowling = Bowling.new
  end

  it "should score 0 for gutter game" do
    20.times { @bowling.hit(0) }
    @bowling.score.should == 0
  end
end

And continue implementing the production code in Java:


public class Bowling {
    public void hit(int pins) {
    }

    public int score() {
        return 0;
    }
}

An important step for JRuby adoption, because this will let Java developers get their Ruby feet wet without having to deal with tons of red tape.

Comments

Leave a response

  1. hornbeckMay 24, 2007 @ 05:10 AM

    That is simply amazing. It almost makes me want to learn a little Java to try it out… I said almost :-) Good stuff,

    John

  2. David BillskogMay 24, 2007 @ 09:06 AM

    Great stuff!

    How well will the rspec mock objects work with java code? Most importantly mocking of the (java) constructor.

    ie. would this work? JavaClass.should_receive(:new).with(...).and_return(...)

  3. Ken BrooksMay 25, 2007 @ 08:33 AM

    got here via your comment about my rspec tutorial series.. in my reply I mentioned that I was excited to try and fit RSpec into my J2EE worklife..

    Low and behold when I arrive to this page the news above smacks me in the face. I’m ecstatic that it will be bundled with JRuby..

    congrats to you guys.

  4. Aníbal RojasMay 27, 2007 @ 02:54 PM

    As a a survivor of Maven and Jelly, and a person that really tried to do testing for its Turbine based apps, I must confess this brings a big smile to my face :-)

  5. Aníbal RojasMay 27, 2007 @ 03:02 PM

    As a a survivor of Maven and Jelly, and a person that really tried to do testing for its Turbine based apps, I must confess this brings a big smile to my face :-)