Roman Numerals Kata, Ruby and RSpec
So I’ve been doing the Roman Numerals kata for nearly a week now – bit bored of it but I’ll swap out on Monday. I’ve been doing it in Ruby, started with test/unit but quickly changed to RSpec to learn the BDD approach.
From what I’ve experienced so far I really like BDD. It feels like the an evolutionary step on from TDD and RSpec in Ruby in particular is very smoothly put together and scans superbly in the code. Here’s a quick example of an RSpec spec:
describe "Roman Numerals Converter" do before :each do @numerals = RomanNumerals.new end context "special symbols" do it "converts 1 to I" do @numerals.toRoman( 1 ).should eq "I" end it "converts 5 to V" do @numerals.toRoman( 5 ).should eq "V" end end end
I’ve uploaded my full Ruby/RSpec solution to GitHub here
Might try combining my next attempt with Cucumber for acceptance tests might keep it interesting until Monday…