Skip to content

Commit

Permalink
Added other style changes
Browse files Browse the repository at this point in the history
Tried to stay out of the 'examples' for the most part.
  • Loading branch information
kotp committed Dec 17, 2014
1 parent a5cd0e4 commit 222049a
Show file tree
Hide file tree
Showing 15 changed files with 245 additions and 132 deletions.
9 changes: 6 additions & 3 deletions allergies/allergies_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ def test_allergic_to_eggs_and_peanuts
def test_allergic_to_lots_of_stuff
skip
allergies = Allergies.new(248)
assert_equal %w(strawberries tomatoes chocolate pollen cats), allergies.list
expected = %w(strawberries tomatoes chocolate pollen cats)
assert_equal expected, allergies.list
end

def test_allergic_to_everything
skip
allergies = Allergies.new(255)
assert_equal %w(eggs peanuts shellfish strawberries tomatoes chocolate pollen cats), allergies.list
expected = %w(eggs peanuts shellfish strawberries tomatoes chocolate pollen cats)
assert_equal expected, allergies.list
end

def test_ignore_non_allergen_score_parts
skip
allergies = Allergies.new(509)
assert_equal %w(eggs shellfish strawberries tomatoes chocolate pollen cats), allergies.list
expected = %w(eggs shellfish strawberries tomatoes chocolate pollen cats)
assert_equal expected, allergies.list
end
end
22 changes: 16 additions & 6 deletions beer-song/beer_song_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,47 @@ def teardown
end

def test_a_typical_verse
expected = "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n"
expected = "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"
assert_equal expected, song.verse(8)
end

def test_another_typical_verse
skip
expected = "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n"
expected = "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"
assert_equal expected, song.verse(3)
end

def test_verse_1
skip
expected = "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"
expected = "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"
assert_equal expected, song.verse(1)
end

def test_verse_2
skip
expected = "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"
expected = "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"
assert_equal expected, song.verse(2)
end

def test_verse_0
skip
expected = "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
expected = "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"
assert_equal expected, song.verse(0)
end

def test_several_verses
skip
expected = "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n\n7 bottles of beer on the wall, 7 bottles of beer.\nTake one down and pass it around, 6 bottles of beer on the wall.\n\n6 bottles of beer on the wall, 6 bottles of beer.\nTake one down and pass it around, 5 bottles of beer on the wall.\n\n"
expected = "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\n" \
"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\n" \
"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\n"
assert_equal expected, song.verses(8, 6)
end

Expand Down
9 changes: 6 additions & 3 deletions crypto-square/crypto_square_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def test_size_is_determined_by_normalized_plaintext
def test_plaintext_segments
skip
crypto = Crypto.new('Never vex thine heart with idle woes')
assert_equal %w(neverv exthin eheart withid lewoes), crypto.plaintext_segments
expected = %w(neverv exthin eheart withid lewoes)
assert_equal expected, crypto.plaintext_segments
end

def test_other_plaintext_segments
Expand Down Expand Up @@ -82,13 +83,15 @@ def test_normalized_ciphertext_spills_into_short_segment
def test_another_normalized_ciphertext
skip
crypto = Crypto.new('If man was meant to stay on the ground god would have given us roots')
assert_equal 'imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghns seoau', crypto.normalize_ciphertext
expected = 'imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghns seoau'
assert_equal expected, crypto.normalize_ciphertext
end

def test_normalized_ciphertext_with_punctuation
skip
crypto = Crypto.new('Have a nice day. Feed the dog & chill out!')
assert_equal 'hifei acedl veeol eddgo aatcu nyhht', crypto.normalize_ciphertext
expected = 'hifei acedl veeol eddgo aatcu nyhht'
assert_equal expected, crypto.normalize_ciphertext
end

def test_normalized_ciphertext_when_just_less_then_a_full_square
Expand Down
5 changes: 1 addition & 4 deletions largest-series-product/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ def initialize(numeric_string)
end

def largest_product(length)
if length > digits.length
fail ArgumentError.new('Not enough digits')
end

fail ArgumentError.new('Not enough digits') if length > digits.length
products = []
slices(length).each do |slice|
products << slice.inject(1) do |product, n|
Expand Down
2 changes: 1 addition & 1 deletion largest-series-product/largest_series_product_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'minitest/autorun'
require_relative 'series'

class SeriesTest < MiniTest::Unit::TestCase
class Seriestest < Minitest::Unit::TestCase
def test_digits
assert_equal (0..9).to_a, Series.new('0123456789').digits
end
Expand Down
2 changes: 1 addition & 1 deletion leap/leap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Date
def leap?
throw "Try to implement this yourself instead of using Ruby's implementation."
throw "Implement this yourself instead of using Ruby's implementation."
end

alias_method :gregorian_leap?, :leap?
Expand Down
Loading

0 comments on commit 222049a

Please sign in to comment.