Last active
August 29, 2015 14:14
-
-
Save squarism/be3425cf89075e05dcd6 to your computer and use it in GitHub Desktop.
Lunch Spec
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
# RSpec really does have an identity crisis. It's not quite ruby and it's | |
# not quite English. But what if we really made our tests complicated | |
# with shared_examples that behave like mixins sorta? How bad would this be? | |
# rspec --format doc lunch_spec.rb | |
shared_examples "charge" do | |
let(:cash_register) { "ding!" } | |
it "charges a price" do | |
puts "That will be $5 please." | |
end | |
end | |
describe "Sandwich Shop" do | |
def announce_order_up | |
puts "Order up!" | |
end | |
context "Food Ordered" do | |
before do | |
puts "Charge the customer" | |
end | |
context "To Go" do | |
before do | |
puts "I'll get a bag ready for you." | |
end | |
it_behaves_like "charge" | |
it "gets out of my store" do | |
puts "Bye!" | |
end | |
end | |
context "For Here" do | |
before do | |
puts "I'll get a tray ready for you." | |
end | |
it_behaves_like "charge" | |
it "uses up my wifi and pretends like they live here" do | |
puts "The wifi password is: WORK_SOMEWHERE_ELSE, all caps." | |
end | |
end | |
end | |
end | |
# Sandwich Shop | |
# Food Ordered | |
# To Go | |
# Charge the customer | |
# I'll get a bag ready for you. | |
# Bye! | |
# gets out of my store | |
# behaves like charge | |
# Charge the customer | |
# I'll get a bag ready for you. | |
# That will be $5 please. | |
# charges a price | |
# For Here | |
# Charge the customer | |
# I'll get a tray ready for you. | |
# The wifi password is: WORK_SOMEWHERE_ELSE, all caps. | |
# uses up my wifi and pretends like they live here | |
# behaves like charge | |
# Charge the customer | |
# I'll get a tray ready for you. | |
# That will be $5 please. | |
# charges a price |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment