3 Variations of Spec Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './numeral_converter' | |
require 'minitest/autorun' | |
describe NumeralConverter do | |
describe "#to_roman" do | |
it "converts 1 to I" do | |
1.must_equal_roman "I" | |
end | |
it "converts 2 to II" do | |
2.must_equal_roman "II" | |
end | |
it "converts 5 to V" do | |
5.must_equal_roman "V" | |
end | |
end | |
end | |
module Minitest::Assertions | |
def assert_equals_roman(roman, integer) | |
assert NumeralConverter.to_roman(integer) == roman, "Expected #{integer} to convert to #{roman}" | |
end | |
end | |
Numeric.infect_an_assertion :assert_equals_roman, :must_equal_roman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './numeral_converter' | |
require 'minitest/autorun' | |
describe NumeralConverter do | |
describe "#to_roman" do | |
let(:roman) { NumeralConverter.to_roman(arabic) } | |
describe "with 1" do | |
let(:arabic) { 1 } | |
it { roman.must_equal "I" } | |
end | |
describe "with 2" do | |
let(:arabic) { 2 } | |
it { roman.must_equal "II" } | |
end | |
describe "with 5" do | |
let(:arabic) { 5 } | |
it { roman.must_equal "V" } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './numeral_converter' | |
require 'minitest/autorun' | |
describe NumeralConverter do | |
describe "#to_roman" do | |
it "converts 1 to I" do | |
NumeralConverter.to_roman(1).must_equal "I" | |
end | |
it "converts 2 to II" do | |
NumeralConverter.to_roman(2).must_equal "II" | |
end | |
it "converts 5 to V" do | |
NumeralConverter.to_roman(2).must_equal "II" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NumeralConverter | |
def self.to_roman(numeral) | |
"I" * numeral | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment