Skip to content

Instantly share code, notes, and snippets.

@noahhendrix
Created December 16, 2011 06:43
Show Gist options
  • Save noahhendrix/1484834 to your computer and use it in GitHub Desktop.
Save noahhendrix/1484834 to your computer and use it in GitHub Desktop.
Testing with datamapper
describe TaskList do
let(:list) { TaskList.new }
let(:todo) { mock('todo').as_null_object }
describe '#tasks' do
context 'without tasks' do
it 'returns an empty array' do
list.tasks.should be_empty
end
end
context 'with tasks' do
before(:each) { list.stub(:tasks).and_return [todo, todo, todo] }
it 'returns an array containing all tasks' do
list.tasks.should =~ [todo, todo, todo]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment