Created
September 10, 2020 07:47
-
-
Save macuk/296661e2b7b0b9ab5f12b2a62edf2ebc to your computer and use it in GitHub Desktop.
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 'test_helper' | |
class LightTest < ActiveSupport::TestCase | |
test 'arguments are valid' do | |
assert_raises(ArgumentError) { Light.new(:pink, :unbroken, Arc.new(0, 90)) } | |
assert_raises(ArgumentError) { Light.new(:white, :test, Arc.new(0, 90)) } | |
assert_raises(ArgumentError) { Light.new(:white, :unbroken, 10) } | |
assert_nothing_raised { Light.new(:white, :unbroken, Arc.new(0, 90)) } | |
end | |
test 'to_s' do | |
masthead_light = Light.new(:white, :unbroken, Arc.new(360 - 112.5, 112.5)) | |
description = 'white unbroken light with arc 225.0 degrees from 247.5 to 112.5' | |
assert_equal description, masthead_light.to_s | |
flashing_light = Light.new(:yellow, :flashing, Arc.new(0, 0)) | |
description = 'yellow flashing light with arc 360 degrees from 0 to 0' | |
assert_equal description, flashing_light.to_s | |
end | |
test 'visible?' do | |
masthead_light = Light.new(:white, :unbroken, Arc.new(360 - 112.5, 112.5)) | |
assert masthead_light.visible?(90) | |
refute masthead_light.visible?(160) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment