Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created November 19, 2013 17:07
Show Gist options
  • Save jimweirich/7548755 to your computer and use it in GitHub Desktop.
Save jimweirich/7548755 to your computer and use it in GitHub Desktop.
For Cincy.rb tonight. Download the following test file. Remove the first "skip" command get the test to pass. Then remove the next "skip" command and continue.
gem 'minitest'
require 'minitest/autorun'
require './beer_song'
class BeerSongTest < Minitest::Test
V8 =
"8 bottles of beer on the wall, 8 bottles of beer.\n" +
"Take one down and pass it around, 7 bottles of beer on the wall.\n"
V7 =
"7 bottles of beer on the wall, 7 bottles of beer.\n" +
"Take one down and pass it around, 6 bottles of beer on the wall.\n"
V6 =
"6 bottles of beer on the wall, 6 bottles of beer.\n" +
"Take one down and pass it around, 5 bottles of beer on the wall.\n"
V3 =
"3 bottles of beer on the wall, 3 bottles of beer.\n" +
"Take one down and pass it around, 2 bottles of beer on the wall.\n"
V2 =
"2 bottles of beer on the wall, 2 bottles of beer.\n" +
"Take one down and pass it around, 1 bottle of beer on the wall.\n"
V1 =
"1 bottle of beer on the wall, 1 bottle of beer.\n" +
"Take it down and pass it around, no more bottles of beer on the wall.\n"
V0 =
"No more bottles of beer on the wall, no more bottles of beer.\n" +
"Go to the store and buy some more, 99 bottles of beer on the wall.\n"
def combine_verses(*verses)
verses.map { |v| "#{v}\n" }.join
end
def beer_song
@beer_song = Beer::Song.new
end
def teardown
@beer_song = nil
end
# Tests ...
def test_a_typical_verse
skip
assert_equal V8, beer_song.verse(8)
end
def test_another_typical_verse
skip
assert_equal V3, beer_song.verse(3)
end
def test_verse_1
skip
assert_equal V1, beer_song.verse(1)
end
def test_verse_2
skip
assert_equal V2, beer_song.verse(2)
end
def test_verse_0
skip
assert_equal V0, beer_song.verse(0)
end
def test_several_verses
skip
expected = combine_verses(V8, V7, V6)
assert_equal expected, beer_song.verses(8, 6)
end
def test_all_the_rest_of_the_verses
skip
expected = combine_verses(V3, V2, V1, V0)
assert_equal expected, beer_song.verses(3)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment