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

Add find_using_max_by_pattern_spec.rb #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
59 changes: 59 additions & 0 deletions enumerables/exercises_1/spec/find_using_max_by_pattern_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
RSpec.describe 'max_by pattern' do
it 'longest word' do
words = ["apple", "banana", "cherry", "date", "eggplant"]
found_word = words.first
words.each do |word|
case word.length <=> found_word.length
when 1
found_word = word
end
end
expect(found_word).to eq("eggplant")
end

xit 'shortest word' do
words = ["apple", "banana", "cherry", "date", "eggplant"]
found_word = words.first
words.each do |word|
# write code here
end
expect(found_word).to eq("date")
end

xit 'array with the most items' do
arrays = [[:a, :b, :c], [1, 2, 3, 4, 5], ["zoo", :things, :stuff]]
biggest_array = arrays.first
# write code here
expect(biggest_array).to eq([1,2,3,4,5])
end

xit 'array with fewest items' do
arrays = [[:a, :b, :c], [1, 2, 3, 4, 5], ["zoo", :things, :stuff]]
# write code here
expect(smallest_array).to eq([:a, :b, :c])
end

xit 'biggest number' do
numbers = [1, 10, 100, 1000, 10000, 1000000]
# write code here
expect(found).to eq(1000000)
end

xit 'smallest number' do
numbers = [1, 10, 100, 1000, 10000, 1000000]
# write code here
expect(found).to eq(1)
end

xit 'most programmers' do
programmers = {ruby: ["katrina", "sandi", "jim", "aaron", "desi"], java: ["abby", "jon", "susan"]}
# write code here
expect(most_programmers.first).to eq(:ruby)
end

xit 'fewest programmers' do
programmers = {ruby: ["katrina", "sandi", "jim", "aaron", "desi"], java: ["abby", "jon", "susan"]}
# write code here
expect(fewest_programmers.first).to eq(:java)
end
end
2 changes: 1 addition & 1 deletion initialize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Traceback (most recent call last):
/Users/joshthompson/.rvm/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- ./lib/beaver (LoadError)
```

You'll have to _create_ the missing file. Look in the `lib` directory, see how the only file is `aardfark.rb`? This error message is saying
You'll have to _create_ the missing file. Look in the `lib` directory, see how the only file is `aardvark.rb`? This error message is saying
> I cannot find ./lib/beaver.rb

So, create a `beaver.rb` file in the `lib` directory, and try it again!
Expand Down
7 changes: 6 additions & 1 deletion mythical-creatures/spec/ogre_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@
ogre = Ogre.new('Brak')
human = Human.new

6.times { ogre.encounter(human) }
5.times { ogre.encounter(human) }

expect(ogre.swings).to eq(1)
expect(human.knocked_out?).to be false

ogre.encounter(human)

expect(ogre.encounter_counter).to eq(6)
expect(ogre.swings).to eq(2)
Expand Down