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.
That is simply amazing. It almost makes me want to learn a little Java to try it out… I said almost :-) Good stuff,
John
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(...)
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.
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 :-)
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 :-)