Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Created August 6, 2010 09:17
Show Gist options
  • Save ashmoran/511087 to your computer and use it in GitHub Desktop.
Save ashmoran/511087 to your computer and use it in GitHub Desktop.
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