Skip to content

Instantly share code, notes, and snippets.

@ctailor2
Created November 19, 2013 20:08
Show Gist options
  • Save ctailor2/7551679 to your computer and use it in GitHub Desktop.
Save ctailor2/7551679 to your computer and use it in GitHub Desktop.
require 'rspec'
describe Cookie do
let(:cookie) { Cookie.new }
context "#initialize" do
it "should create a cookie object" do
cookie.should be_an_instance_of Cookie
end
it "should have 0 baking time" do
cookie.baking_time.should == 0
end
end
context "#bake" do
it "should increment baking time by 1" do
expect { cookie.bake }.to change { cookie.baking_time }.by(1)
end
end
context "#status" do
it "returns the cookie's current status"
context "when baked for 0 minutes" do
it "is `:raw`" do
cookie.status.should == :raw
end
end
context "when baked for less than 7 minutes" do
it "is `:soggy`" do
rand(1..6).times do
cookie.bake
end
cookie.status.should == :soggy
end
end
context "when baked for at least 7 but less than 10 minutes" do
it "is `:chewy_ready`" do
rand(7..9).times do
cookie.bake
end
cookie.status.should == :chewy_ready
end
end
context "when baked for at least 10 but less than 12 minutes" do
it "is `:crispy_ready`" do
rand(10..11).times do
cookie.bake
end
cookie.status.should == :crispy_ready
end
end
context "when baked for at least 12 minutes" do
it "is `:burned`" do
rand(12..40).times do
cookie.bake
end
cookie.status.should == :burned
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment