fjord/main_test.rb
2024-03-30 22:05:45 +09:00

46 lines
1.2 KiB
Ruby

require 'minitest/autorun'
require_relative 'main'
class EffectTest < Minitest::Test
def test_reverse
effect = Effects.reverse
assert_equal 'ybuR si !nuf', effect.call('Ruby is fun!')
end
def test_echo
effect = Effects.echo(2)
assert_equal 'RRuubbyy iiss ffuunn!!', effect.call('Ruby is fun!')
effect = Effects.echo(3)
assert_equal 'RRRuuubbbyyy iiisss fffuuunnn!!!', effect.call('Ruby is fun!')
end
def test_loud
effect = Effects.loud(2)
assert_equal 'RUBY!! IS!! FUN!!!', effect.call('Ruby is fun!')
effect = Effects.loud(3)
assert_equal 'RUBY!!! IS!!! FUN!!!!', effect.call('Ruby is fun!')
end
end
class WordSynthTest < Minitest::Test
def test_play_without_effects
synth = WordSynth.new
assert_equal 'Ruby is fun!', synth.play('Ruby is fun!')
end
def test_play_with_reverse
synth = WordSynth.new
synth.add_effect(Effects.reverse)
assert_equal 'ybuR si !nuf', synth.play('Ruby is fun!')
end
def test_play_with_many_effects
synth = WordSynth.new
synth.add_effect(Effects.echo(2))
synth.add_effect(Effects.loud(3))
synth.add_effect(Effects.reverse)
assert_equal '!!!YYBBUURR !!!SSII !!!!!NNUUFF', synth.play('Ruby is fun!')
end
end