Skip to content
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
7 changes: 7 additions & 0 deletions furlong.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ class Furlong
def miles_to_kilometers(miles)
miles * KM_PER_MILE
end
end

class Reverse_Furlong
FURLONG_PER_KM = 0.201168
def furlong_to_kilometers(km)
km * FURLONG_PER_KM
end
end
10 changes: 10 additions & 0 deletions furlong_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@
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
end

describe Reverse_Furlong do

let(:calculator) {Furlong.new}

it "converts 1 furlong to 0.201168 kilometers" do
subject.furlong_to_kilometers(1).should be_within(0.0001).of(0.201168)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above you declare a calculator, but you never use it.

I think you should either:

let(:calculator) {Furlong.new}
it "converts 1 furlong to 0.201168 kilometers" do
  calculator.furlong_to_kilometers(1).should be_within(0.0001).of(0.201168)
end

OR

it "converts 1 furlong to 0.201168 kilometers" do
  subject.furlong_to_kilometers(1).should be_within(0.0001).of(0.201168)
end

end

end