Create a Monkey
class in lib/monkey.rb
, which has the following attributes:
name
- a string, which should be determined by some inputspecies
- a string, which should be determined by some inputfoods_eaten
- an array, which should be initialized as an empty array
And the following methods:
eat(food)
- adds a food (a string) to the list of foods eatenintroduce
- 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.