Last active
December 14, 2015 05:29
-
-
Save novohispano/5035831 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "Apple" do | |
let (:apple) { Fruit::Apple.new } | |
describe "#initialize" do | |
context "when given no parameters" do | |
it "variety is 'Granny Smith'" do | |
expect(apple.variety).to eq "Granny Smith" | |
end | |
end | |
context "when given a variety parameter" do | |
it "variety is the specified variety" do | |
apple = Fruit::Apple.new("Pink Lady") | |
expect(apple.variety).to eq "Pink Lady" | |
end | |
end | |
end | |
describe "#slice" do | |
context "when given no parameters" do | |
it "returns removes one slice of the apple" do | |
expect(apple.slice).to eq 1 | |
end | |
it "reports the correct number of remaining slices" do | |
apple.stub(:apple_size => 8) | |
apple.slice | |
expect(apple.remaining_slices).to eq 7 | |
end | |
end | |
context "when given a number of slices parameter" do | |
it "returns the correct number of slices" do | |
expect(apple.slice(3)).to eq 3 | |
end | |
it "reports the correct number of remaining slices" do | |
apple.stub(:apple_size => 8) | |
apple.slice(3) | |
expect(apple.remaining_slices).to eq 5 | |
end | |
end | |
context "when given a number of slices parameter greater than the remaining slices" do | |
it "returns the number of remaining slices" do | |
apple.stub(:apple_size => 8) | |
expect(apple.slice(10)).to eq 8 | |
end | |
it "returns the correct number of remaining slices" do | |
apple.stub(:apple_size => 8) | |
apple.slice(10) | |
expect(apple.remaining_slices).to eq 8 | |
end | |
end | |
end | |
describe "#ripe?" do | |
context "when apple is created" do | |
it "returns false when apple is younger than 10 seconds" do | |
apple.stub(:age => 9) | |
expect(apple.ripe?).to eq false | |
end | |
it "returns true when apple is older than 10 seconds" do | |
apple.stub(:age => 11) | |
expect(apple.ripe?).to eq true | |
end | |
end | |
end | |
describe "#unripe?" do | |
context "when apple is created" do | |
it "returns true when apple is younger than 10 seconds" do | |
apple.stub(:age => 9) | |
expect(apple.unripe?).to eq true | |
end | |
it "returns false when apple is older than 10 seconds" do | |
apple.stub(:age => 11) | |
expect(apple.unripe?).to eq false | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment