Created
January 29, 2012 19:51
-
-
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
This file contains 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
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