Skip to content

Instantly share code, notes, and snippets.

@lenny
Created January 29, 2012 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenny/1700352 to your computer and use it in GitHub Desktop.
Save lenny/1700352 to your computer and use it in GitHub Desktop.
macros approach to requestable examples as expressed in http://mutuallyhuman.com/blog/2012/01/27/rspec-requestable-examples
module WordListMacros
def it_strips_double_quotes
it "strips double quotes" do
subject.list_of_words = %w("foo" "bar")
subject.list_of_words.should eq(%w(foo bar))
end
end
def it_strips_single_quotes
it "strips single quotes" do
subject.list_of_words = %w('foo' 'bar')
subject.list_of_words.should eq(%w(foo bar))
end
end
def it_allows_standard_non_alphanumeric_chars
it "allows '!, ?, @, #, $, %, &, *, -, +, _ :, .' characters" do
...
end
end
end
describe FirstWordList do
extend WordListMacros
it_strips_single_quotes
it_strips_double_quotes
...
end
describe SecondWordList do
extend WordListMacros
it_strips_double_quotes
it_allows_standard_non_alphanumeric_chars
...
it 'does something special to SecondWordList'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment