Skip to content
Merged
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
2 changes: 1 addition & 1 deletion space-age/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize(seconds)
}.each do |planet, orbital_period|

define_method("on_#{planet}") do
(seconds / orbital_period).round(2)
seconds / orbital_period
end

end
Expand Down
34 changes: 18 additions & 16 deletions space-age/space_age_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,65 @@
require_relative 'space_age'

class SpaceAgeTest < Minitest::Test
DELTA = 0.01

def test_age_in_seconds
age = SpaceAge.new(1_000_000)
assert_equal 1_000_000, age.seconds
assert_in_delta 1_000_000, age.seconds, DELTA
end

def test_age_in_earth_years
skip
age = SpaceAge.new(1_000_000_000)
assert_equal 31.69, age.on_earth
assert_in_delta 31.69, age.on_earth, DELTA
end

def test_age_in_mercury_years
skip
age = SpaceAge.new(2_134_835_688)
assert_equal 67.65, age.on_earth
assert_equal 280.88, age.on_mercury
assert_in_delta 67.65, age.on_earth, DELTA
assert_in_delta 280.88, age.on_mercury, DELTA
end

def test_age_in_venus_years
skip
age = SpaceAge.new(189_839_836)
assert_equal 6.02, age.on_earth
assert_equal 9.78, age.on_venus
assert_in_delta 6.02, age.on_earth, DELTA
assert_in_delta 9.78, age.on_venus, DELTA
end

def test_age_on_mars
skip
age = SpaceAge.new(2_329_871_239)
assert_equal 73.83, age.on_earth
assert_equal 39.25, age.on_mars
assert_in_delta 73.83, age.on_earth, DELTA
assert_in_delta 39.25, age.on_mars, DELTA
end

def test_age_on_jupiter
skip
age = SpaceAge.new(901_876_382)
assert_equal 28.58, age.on_earth
assert_equal 2.41, age.on_jupiter
assert_in_delta 28.58, age.on_earth, DELTA
assert_in_delta 2.41, age.on_jupiter, DELTA
end

def test_age_on_saturn
skip
age = SpaceAge.new(3_000_000_000)
assert_equal 95.06, age.on_earth
assert_equal 3.23, age.on_saturn
assert_in_delta 95.06, age.on_earth, DELTA
assert_in_delta 3.23, age.on_saturn, DELTA
end

def test_age_on_uranus
skip
age = SpaceAge.new(3_210_123_456)
assert_equal 101.72, age.on_earth
assert_equal 1.21, age.on_uranus
assert_in_delta 101.72, age.on_earth, DELTA
assert_in_delta 1.21, age.on_uranus, DELTA
end

def test_age_on_neptune
skip
age = SpaceAge.new(8_210_123_456)
assert_equal 260.16, age.on_earth
assert_equal 1.58, age.on_neptune
assert_in_delta 260.16, age.on_earth, DELTA
assert_in_delta 1.58, age.on_neptune, DELTA
end
end