|
1 | 1 | #!/usr/bin/env ruby
|
| 2 | +# encoding: utf-8 |
2 | 3 | gem 'minitest', '>= 5.0.0'
|
3 | 4 | require 'minitest/autorun'
|
4 | 5 | require_relative 'beer_song'
|
5 | 6 |
|
| 7 | +# Common test data version: e699ab6 |
6 | 8 | class BeerSongTest < Minitest::Test
|
7 |
| - def test_the_first_verse |
8 |
| - expected = "99 bottles of beer on the wall, 99 bottles of beer.\n" \ |
9 |
| - "Take one down and pass it around, 98 bottles of beer on the wall.\n" |
| 9 | + def test_first_verse |
| 10 | + # skip |
| 11 | + expected = <<-TEXT |
| 12 | +99 bottles of beer on the wall, 99 bottles of beer. |
| 13 | +Take one down and pass it around, 98 bottles of beer on the wall. |
| 14 | +TEXT |
10 | 15 | assert_equal expected, BeerSong.new.verse(99)
|
11 | 16 | end
|
12 | 17 |
|
13 |
| - def test_another_verse |
| 18 | + def test_middle_verse |
14 | 19 | skip
|
15 |
| - expected = "3 bottles of beer on the wall, 3 bottles of beer.\n" \ |
16 |
| - "Take one down and pass it around, 2 bottles of beer on the wall.\n" |
17 |
| - assert_equal expected, BeerSong.new.verse(3) |
| 20 | + expected = <<-TEXT |
| 21 | +44 bottles of beer on the wall, 44 bottles of beer. |
| 22 | +Take one down and pass it around, 43 bottles of beer on the wall. |
| 23 | +TEXT |
| 24 | + assert_equal expected, BeerSong.new.verse(44) |
18 | 25 | end
|
19 | 26 |
|
20 |
| - def test_verse_2 |
| 27 | + def test_third_to_last_verse |
21 | 28 | skip
|
22 |
| - expected = "2 bottles of beer on the wall, 2 bottles of beer.\n" \ |
23 |
| - "Take one down and pass it around, 1 bottle of beer on the wall.\n" |
| 29 | + expected = <<-TEXT |
| 30 | +2 bottles of beer on the wall, 2 bottles of beer. |
| 31 | +Take one down and pass it around, 1 bottle of beer on the wall. |
| 32 | +TEXT |
24 | 33 | assert_equal expected, BeerSong.new.verse(2)
|
25 | 34 | end
|
26 | 35 |
|
27 |
| - def test_verse_1 |
| 36 | + def test_penultimate_verse |
28 | 37 | skip
|
29 |
| - expected = "1 bottle of beer on the wall, 1 bottle of beer.\n" \ |
30 |
| - "Take it down and pass it around, no more bottles of beer on the wall.\n" |
| 38 | + expected = <<-TEXT |
| 39 | +1 bottle of beer on the wall, 1 bottle of beer. |
| 40 | +Take it down and pass it around, no more bottles of beer on the wall. |
| 41 | +TEXT |
31 | 42 | assert_equal expected, BeerSong.new.verse(1)
|
32 | 43 | end
|
33 | 44 |
|
34 |
| - def test_verse_0 |
| 45 | + def test_last_verse |
35 | 46 | skip
|
36 |
| - expected = "No more bottles of beer on the wall, no more bottles of beer.\n" \ |
37 |
| - "Go to the store and buy some more, 99 bottles of beer on the wall.\n" |
| 47 | + expected = <<-TEXT |
| 48 | +No more bottles of beer on the wall, no more bottles of beer. |
| 49 | +Go to the store and buy some more, 99 bottles of beer on the wall. |
| 50 | +TEXT |
38 | 51 | assert_equal expected, BeerSong.new.verse(0)
|
39 | 52 | end
|
40 | 53 |
|
41 |
| - def test_a_couple_verses |
| 54 | + def test_last_4_verses |
42 | 55 | skip
|
43 |
| - expected = "99 bottles of beer on the wall, 99 bottles of beer.\n" \ |
44 |
| - "Take one down and pass it around, 98 bottles of beer on the wall.\n" \ |
45 |
| - "\n" \ |
46 |
| - "98 bottles of beer on the wall, 98 bottles of beer.\n" \ |
47 |
| - "Take one down and pass it around, 97 bottles of beer on the wall.\n" |
48 |
| - assert_equal expected, BeerSong.new.verses(99, 98) |
49 |
| - end |
| 56 | + expected = <<-TEXT |
| 57 | +3 bottles of beer on the wall, 3 bottles of beer. |
| 58 | +Take one down and pass it around, 2 bottles of beer on the wall. |
50 | 59 |
|
51 |
| - def test_a_few_verses |
52 |
| - skip |
53 |
| - expected = "2 bottles of beer on the wall, 2 bottles of beer.\n" \ |
54 |
| - "Take one down and pass it around, 1 bottle of beer on the wall.\n" \ |
55 |
| - "\n" \ |
56 |
| - "1 bottle of beer on the wall, 1 bottle of beer.\n" \ |
57 |
| - "Take it down and pass it around, no more bottles of beer on the wall.\n" \ |
58 |
| - "\n" \ |
59 |
| - "No more bottles of beer on the wall, no more bottles of beer.\n" \ |
60 |
| - "Go to the store and buy some more, 99 bottles of beer on the wall.\n" |
61 |
| - assert_equal expected, BeerSong.new.verses(2, 0) |
| 60 | +2 bottles of beer on the wall, 2 bottles of beer. |
| 61 | +Take one down and pass it around, 1 bottle of beer on the wall. |
| 62 | +
|
| 63 | +1 bottle of beer on the wall, 1 bottle of beer. |
| 64 | +Take it down and pass it around, no more bottles of beer on the wall. |
| 65 | +
|
| 66 | +No more bottles of beer on the wall, no more bottles of beer. |
| 67 | +Go to the store and buy some more, 99 bottles of beer on the wall. |
| 68 | +TEXT |
| 69 | + assert_equal expected, BeerSong.new.lyrics(3, 0) |
62 | 70 | end
|
63 | 71 |
|
64 |
| - def test_the_whole_song |
| 72 | + def test_all_verses |
65 | 73 | skip
|
66 |
| - expected = <<-SONG |
| 74 | + expected = <<-TEXT |
67 | 75 | 99 bottles of beer on the wall, 99 bottles of beer.
|
68 | 76 | Take one down and pass it around, 98 bottles of beer on the wall.
|
69 | 77 |
|
@@ -363,18 +371,27 @@ def test_the_whole_song
|
363 | 371 |
|
364 | 372 | No more bottles of beer on the wall, no more bottles of beer.
|
365 | 373 | Go to the store and buy some more, 99 bottles of beer on the wall.
|
366 |
| - SONG |
367 |
| - assert_equal expected, BeerSong.new.lyrics |
| 374 | +TEXT |
| 375 | + assert_equal expected, BeerSong.new.lyrics(99, 0) |
368 | 376 | end
|
369 |
| - |
370 |
| - # Problems in exercism evolve over time, |
371 |
| - # as we find better ways to ask questions. |
| 377 | + # Problems in exercism evolve over time, as we find better ways to ask |
| 378 | + # questions. |
372 | 379 | # The version number refers to the version of the problem you solved,
|
373 | 380 | # not your solution.
|
374 | 381 | #
|
375 |
| - # Define a constant named VERSION inside of BookKeeping. |
| 382 | + # Define a constant named VERSION inside of the top level BookKeeping |
| 383 | + # module, which may be placed near the end of your file. |
| 384 | + # |
| 385 | + # In your file, it will look like this: |
| 386 | + # |
| 387 | + # module BookKeeping |
| 388 | + # VERSION = 1 # Where the version number matches the one in the test. |
| 389 | + # end |
| 390 | + # |
| 391 | + # If you are curious, read more about constants on RubyDoc: |
| 392 | + # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html |
376 | 393 | def test_bookkeeping
|
377 | 394 | skip
|
378 |
| - assert_equal 2, BookKeeping::VERSION |
| 395 | + assert_equal 3, BookKeeping::VERSION |
379 | 396 | end
|
380 | 397 | end
|
0 commit comments