Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rspec'
class Quiz
def self.answer(question)
42
end
end
# Test
module MyMacro
def should_answer(question, answer)
it "should answer '#{question}' with #{answer}" do
Quiz.answer(question).should == answer
end
end
end
RSpec.configure do |config|
config.extend MyMacro
end
describe Quiz do
ANSWER = 42
before(:all) do
# @answer = 42
end
should_answer("What's the meaning of life?", ANSWER)
should_answer("What comes after 41?", ANSWER)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment