Create a Monkey
class in lib/monkey.rb
, which has the following attributes:
- name - (a string)
- species - (a string)
- foods_eaten - (an array)
And the following methods:
- eat(food) - adds the food (a string) to the list of foods eaten
- introduce - introduces self, with name, species, and what it's eaten.
Run tests using rspec
from inside the oop_monkey
folder (not in any subfolders). Write code in your Monkey class to make the tests pass.
Note:
- You should not need to alter the
monkey_spec
file in any way (except for the bonus below). - You shouldn't need to run
ruby lib/monkey.rb
or use theruby
command at all -- justrspec
. - You can completely ignore the
.rspec
andspec_helper.rb
files.
RSpec is a tool for writing automated tests for programs written in ruby. We
write tests in ruby (see spec/monkey_spec.rb
for example), that describe what
we expect to happen when we use our code (usually classes/objects).
When we run the tests, it compares what our code does to what our tests expect, and tells us which pass and which fail.
Uncomment the bonus tests in spec/monkey_spec
and make them pass.