Skip to content

Commit

Permalink
Merge pull request #929 from ccouzens/master
Browse files Browse the repository at this point in the history
Use squiqqly heredoc in tests
  • Loading branch information
emcoding authored Mar 25, 2019
2 parents d7ee05e + 5fc4dad commit ed38a91
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 64 deletions.
2 changes: 1 addition & 1 deletion exercises/beer-song/.meta/generator/beer_song_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class BeerSongCase < Generator::ExerciseCase
def workload
[
"expected = #{indent_heredoc(expected, 'TEXT', 0, ".gsub(/^ */, '')" )}\n",
"expected = #{indent_heredoc(expected, 'TEXT' )}\n",
"assert_equal expected, BeerSong.recite(#{start_bottles}, #{take_down})\n"
].join
end
Expand Down
16 changes: 8 additions & 8 deletions exercises/beer-song/beer_song_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class BeerSongTest < Minitest::Test
def test_first_generic_verse
# skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
TEXT
Expand All @@ -14,7 +14,7 @@ def test_first_generic_verse

def test_last_generic_verse
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.
TEXT
Expand All @@ -23,7 +23,7 @@ def test_last_generic_verse

def test_verse_with_2_bottles
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
TEXT
Expand All @@ -32,7 +32,7 @@ def test_verse_with_2_bottles

def test_verse_with_1_bottle
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.
TEXT
Expand All @@ -41,7 +41,7 @@ def test_verse_with_1_bottle

def test_verse_with_0_bottles
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
TEXT
Expand All @@ -50,7 +50,7 @@ def test_verse_with_0_bottles

def test_first_two_verses
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
Expand All @@ -62,7 +62,7 @@ def test_first_two_verses

def test_last_three_verses
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
Expand All @@ -77,7 +77,7 @@ def test_last_three_verses

def test_all_verses
skip
expected = <<-TEXT.gsub(/^ */, '')
expected = <<~TEXT
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
Expand Down
10 changes: 2 additions & 8 deletions exercises/tournament/.meta/generator/tournament_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
class TournamentCase < Generator::ExerciseCase
def workload
[
"input = #{indent_heredoc(rows, 'INPUT', 0, delimiter_mod)}\n\n",
"expected = #{indent_heredoc(expected, 'TALLY', 0, delimiter_mod)}\n\n",
"input = #{indent_heredoc(rows, 'INPUT')}\n\n",
"expected = #{indent_heredoc(expected, 'TALLY')}\n\n",
"assert_equal expected, Tournament.tally(input)"
]
end

private

def delimiter_mod
".gsub(/^ */, '')"
end
end
44 changes: 22 additions & 22 deletions exercises/tournament/tournament_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
class TournamentTest < Minitest::Test
def test_just_the_header_if_no_input
# skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
TALLY

Expand All @@ -18,11 +18,11 @@ def test_just_the_header_if_no_input

def test_a_win_is_three_points_a_loss_is_zero_points
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;win
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 1 | 1 | 0 | 0 | 3
Blithering Badgers | 1 | 0 | 0 | 1 | 0
Expand All @@ -33,11 +33,11 @@ def test_a_win_is_three_points_a_loss_is_zero_points

def test_a_win_can_also_be_expressed_as_a_loss
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Blithering Badgers;Allegoric Alaskans;loss
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 1 | 1 | 0 | 0 | 3
Blithering Badgers | 1 | 0 | 0 | 1 | 0
Expand All @@ -48,11 +48,11 @@ def test_a_win_can_also_be_expressed_as_a_loss

def test_a_different_team_can_win
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Blithering Badgers;Allegoric Alaskans;win
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Blithering Badgers | 1 | 1 | 0 | 0 | 3
Allegoric Alaskans | 1 | 0 | 0 | 1 | 0
Expand All @@ -63,11 +63,11 @@ def test_a_different_team_can_win

def test_a_draw_is_one_point_each
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;draw
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 1 | 0 | 1 | 0 | 1
Blithering Badgers | 1 | 0 | 1 | 0 | 1
Expand All @@ -78,12 +78,12 @@ def test_a_draw_is_one_point_each

def test_there_can_be_more_than_one_match
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;win
Allegoric Alaskans;Blithering Badgers;win
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 2 | 2 | 0 | 0 | 6
Blithering Badgers | 2 | 0 | 0 | 2 | 0
Expand All @@ -94,12 +94,12 @@ def test_there_can_be_more_than_one_match

def test_there_can_be_more_than_one_winner
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;loss
Allegoric Alaskans;Blithering Badgers;win
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 2 | 1 | 0 | 1 | 3
Blithering Badgers | 2 | 1 | 0 | 1 | 3
Expand All @@ -110,13 +110,13 @@ def test_there_can_be_more_than_one_winner

def test_there_can_be_more_than_two_teams
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;win
Blithering Badgers;Courageous Californians;win
Courageous Californians;Allegoric Alaskans;loss
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 2 | 2 | 0 | 0 | 6
Blithering Badgers | 2 | 1 | 0 | 1 | 3
Expand All @@ -128,7 +128,7 @@ def test_there_can_be_more_than_two_teams

def test_typical_input
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;win
Devastating Donkeys;Courageous Californians;draw
Devastating Donkeys;Allegoric Alaskans;win
Expand All @@ -137,7 +137,7 @@ def test_typical_input
Allegoric Alaskans;Courageous Californians;win
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Devastating Donkeys | 3 | 2 | 1 | 0 | 7
Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
Expand All @@ -150,14 +150,14 @@ def test_typical_input

def test_incomplete_competition_not_all_pairs_have_played
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Allegoric Alaskans;Blithering Badgers;loss
Devastating Donkeys;Allegoric Alaskans;loss
Courageous Californians;Blithering Badgers;draw
Allegoric Alaskans;Courageous Californians;win
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
Blithering Badgers | 2 | 1 | 1 | 0 | 4
Expand All @@ -170,7 +170,7 @@ def test_incomplete_competition_not_all_pairs_have_played

def test_ties_broken_alphabetically
skip
input = <<-INPUT.gsub(/^ */, '')
input = <<~INPUT
Courageous Californians;Devastating Donkeys;win
Allegoric Alaskans;Blithering Badgers;win
Devastating Donkeys;Allegoric Alaskans;loss
Expand All @@ -179,7 +179,7 @@ def test_ties_broken_alphabetically
Allegoric Alaskans;Courageous Californians;draw
INPUT

expected = <<-TALLY.gsub(/^ */, '')
expected = <<~TALLY
Team | MP | W | D | L | P
Allegoric Alaskans | 3 | 2 | 1 | 0 | 7
Courageous Californians | 3 | 2 | 1 | 0 | 7
Expand Down
2 changes: 1 addition & 1 deletion exercises/transpose/.meta/generator/transpose_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def workload
private

def delimiter_mod
".gsub(/^ {6}/, '').strip"
".strip"
end

end
Loading

0 comments on commit ed38a91

Please sign in to comment.