Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All good! #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions furlong.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
class Furlong

KM_PER_MILE = 1.60934
KM_PER_FURLONG = 0.201168
def miles_to_kilometers(miles)
miles * KM_PER_MILE
end

def furlongs_to_kilometers(furlongs)
furlongs * KM_PER_FURLONG
end
end
4 changes: 4 additions & 0 deletions furlong_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
it "converts a marathon: 26.219 miles to 42.194988 km" do
subject.miles_to_kilometers(26.219).should be_within(0.001).of(42.194988)
end

it "converts 1 furlong to 0.201168 kilometers" do
subject.furlongs_to_kilometers(1).should be_within(0.001).of(0.201168)
end
end
5 changes: 5 additions & 0 deletions furlong_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def test_marathon
assert_in_delta 42.194, km, 0.01
end

def test_furlong
km = Furlong.new.furlongs_to_kilometers(1)
assert_in_delta 0.201168, km, 0.001
end

end

describe Furlong do
Expand Down