Skip to content

Instantly share code, notes, and snippets.

@arwagner
Created November 17, 2010 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arwagner/703446 to your computer and use it in GitHub Desktop.
Save arwagner/703446 to your computer and use it in GitHub Desktop.
MarbleMachine spec
shared_examples_for "blue green yellow" do
let(:current_context) { [:blue, :green, :yellow].each {|color| machine.insert color }; machine }
end
shared_examples_for "small medium large" do
let(:current_context) { [:small, :medium, :large].each {|size| machine.press size }; machine }
end
describe MarbleMachine do
let(:machine) { MarbleMachine.new }
context "varying contexts across the same action" do
context "blue green yellow" do
it_should_behave_like "blue green yellow"
it "should return 73" do
m = current_context;
5.times { m.insert :red }
m.output.should == 73
end
end
context "blue green purple" do
it_should_behave_like "small medium large"
it "should return 37" do
m = current_context
5.times { m.insert :red }
m.output.should == 73
end
end
end
context "varying actions across the same context" do
context "blue green yellow" do
it_should_behave_like "blue green yellow"
context "inserting purple" do
it "should return 22" do
m = current_context
m.insert :purple
m.output.should == 22
end
end
context "inserting red" do
it "should return 38" do
m = current_context
m.insert :red
m.output.should == 38
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment