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

Finished assignment. #14

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
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