Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list-challenge #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions mytest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require 'minitest/autorun'
require 'pry'

class ListAnalyzer
def initialize
list = ["apple","banana","orange"]
@word = list.sample
end


def some_word_starts_with_a_vowel?(mostly_consonants)
if word.start_with?('a','e','i','o','u')
word
else
nil
end
end

class ListTest < MiniTest::Test
def test_it_can_count_vowels
produce = ["apricot", "beet", "clementine", "date", "elderberry"]

lister = ListAnalyzer.new

assert_equal 2, lister.number_of_words_starting_with_a_vowel(produce)
end

def test_it_can_check_a_whole_list_for_matches
mostly_vowels = ["iceberg", "ugli", "endive", "plum", "olive"]

lister = ListAnalyzer.new
refute lister.all_words_start_with_vowels?(mostly_vowels)

mostly_vowels.delete "plum"
assert lister.all_words_start_with_vowels?(mostly_vowels)
end

def test_it_can_check_for_a_single_example
mostly_consonants = ["pear", "quince", "aubergine", "zucchini", "pineapple"]

lister = ListAnalyzer.new
assert lister.some_word_starts_with_a_vowel?(mostly_consonants)

mostly_consonants.delete "aubergine"
refute lister.some_word_starts_with_a_vowel?(mostly_consonants)
end

def test_it_can_count_all_vowels
produce = ["apricot", "beet", "clementine", "date", "elderberry"]

lister = ListAnalyzer.new

assert_equal 14, lister.number_of_vowels_in_all_words(produce)
end
end
end