Create a gist now

Instantly share code, notes, and snippets.

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