Skip to content

Instantly share code, notes, and snippets.

@anewusername1
Created December 2, 2011 15:42
Show Gist options
  • Save anewusername1/1423678 to your computer and use it in GitHub Desktop.
Save anewusername1/1423678 to your computer and use it in GitHub Desktop.
bad rspec test
it "should allow only strings that include the letter 'a'" do
StringAllower.allowed?('a bed').should == true
StringAllower.allowed?('my bed').should == false
StringAllower.allowed?('single bed').should == false
StringAllower.allowed?('a single bed').should == true
StringAllower.allowed?('some car').should == true
StringAllower.allowed?('some motorcycle').should == false
....
end
describe 'allowed?' do
['a bed', 'a single bed', 'some car'].each do |allowed_word|
context "with allowed word: #{allowed_word}" do
let(:word) { allowed_word }
specify { StringAllower.allowed?(word).should be_true }
end
end
['my bed', 'single bed', 'some motorcycle'].each do |disallowed_word|
context "with disallowed word: #{disallowed_word}" do
let(:word) { disallowed_word }
specify { StringAllower.allowed?(word).should be_false }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment