|
require 'rspec' |
|
|
|
describe Cookie do |
|
let(:cookie) { Cookie.new("oatmeal", 10) } |
|
|
|
context '#initialize' do |
|
it 'creates a Cookie object' do |
|
cookie.should be_an_instance_of Cookie |
|
end |
|
|
|
it 'requires two parameters' do |
|
expect { Cookie.new }.to raise_error |
|
end |
|
|
|
it 'has a valid type' do |
|
expect { Cookie.new(10, 10) }.to raise_error |
|
end |
|
|
|
it 'has a numeric baketime' do |
|
expect { Cookie.new('chocolate', 'chip') }.to raise_error |
|
end |
|
end |
|
end |
|
|
|
describe Batch do |
|
let(:batch) { Batch.new(24, "oatmeal", 10) } |
|
|
|
context '#initialize' do |
|
it 'creates an Batch object' do |
|
batch.should be_an_instance_of Batch |
|
end |
|
|
|
it 'requires four parameters' do |
|
expect { Batch.new }.to raise_error |
|
end |
|
end |
|
|
|
|
|
context '#cookies' do |
|
it 'returns an array' do |
|
batch.cookies.should be_an_instance_of Array |
|
end |
|
|
|
it 'has a cookie object in the array' do |
|
batch.cookies[0].should be_an_instance_of Cookie |
|
end |
|
|
|
it 'has correct number of cookies' do |
|
batch.cookies.length.should eq 24 |
|
end |
|
end |
|
|
|
context '#baketime' do |
|
it 'has correct baketime' do |
|
batch.baketime.should eq 10 |
|
end |
|
end |
|
|
|
context '#done' do |
|
it "requires a parameter" do |
|
expect { Batch.new(10, "good", 10).done }.to raise_error |
|
end |
|
it 'returns true if batch is done' do |
|
expect { Batch.new(10, "good", 10).done(10) }.to be_true |
|
end |
|
|
|
it 'returns true if batch is done' do |
|
expect { Batch.new(10, "good", 10).done(8) }.to be_false |
|
end |
|
end |
|
end |