1
exercism fetch ruby proverb

proverb_test.rb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'minitest/autorun'
require_relative 'proverb'

class ProverbTest < Minitest::Test
  def test_a_single_consequence
    proverb = Proverb.new('nail', 'shoe')
    expected = "For want of a nail the shoe was lost.\n" \
      'And all for the want of a nail.'
    assert_equal expected, proverb.to_s
  end

  def test_a_short_chain_of_consequences
    skip
    proverb = Proverb.new('nail', 'shoe', 'horse')
    expected = "For want of a nail the shoe was lost.\n" \
      "For want of a shoe the horse was lost.\n" \
      'And all for the want of a nail.'
    assert_equal expected, proverb.to_s
  end

  def test_a_longer_chain_of_consequences
    skip
    proverb = Proverb.new('nail', 'shoe', 'horse', 'rider')
    expected = "For want of a nail the shoe was lost.\n" \
      "For want of a shoe the horse was lost.\n" \
      "For want of a horse the rider was lost.\n" \
      'And all for the want of a nail.'
    assert_equal expected, proverb.to_s
  end

  def test_proverb_does_not_hard_code_the_rhyme_dictionary
    skip
    proverb = Proverb.new('key', 'value')
    expected = "For want of a key the value was lost.\n" \
      'And all for the want of a key.'
    assert_equal expected, proverb.to_s
  end

  def test_the_whole_proverb
    skip
    chain = %w(nail shoe horse rider message battle kingdom)
    proverb = Proverb.new(*chain)
    expected = "For want of a nail the shoe was lost.\n" \
      "For want of a shoe the horse was lost.\n" \
      "For want of a horse the rider was lost.\n" \
      "For want of a rider the message was lost.\n" \
      "For want of a message the battle was lost.\n" \
      "For want of a battle the kingdom was lost.\n" \
      'And all for the want of a nail.'
    assert_equal expected, proverb.to_s
  end

  def test_an_optional_qualifier_in_the_final_consequence
    skip
    chain = %w(nail shoe horse rider message battle kingdom)
    proverb = Proverb.new(*chain, qualifier: 'horseshoe')
    expected = "For want of a nail the shoe was lost.\n" \
      "For want of a shoe the horse was lost.\n" \
      "For want of a horse the rider was lost.\n" \
      "For want of a rider the message was lost.\n" \
      "For want of a message the battle was lost.\n" \
      "For want of a battle the kingdom was lost.\n" \
      'And all for the want of a horseshoe nail.'
    assert_equal expected, proverb.to_s
  end

  def test_proverb_is_same_each_time
    skip
    proverb = Proverb.new('nail', 'shoe')
    assert_equal proverb.to_s, proverb.to_s
  end
end