Skip to content

Instantly share code, notes, and snippets.

Created April 10, 2011 09:02
Show Gist options
  • Save anonymous/912172 to your computer and use it in GitHub Desktop.
Save anonymous/912172 to your computer and use it in GitHub Desktop.
catalog of books
def setup()
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("testbooks")
end
@books = Books.new(title: 'Turn of a Screw', author: "Henry James", barcode: '666')
end
def test_barcode
# Test for uniqueness of each book barcode
# Compare to whole, must not match any
assert_equal(@books, Books.where(author: 'Henry James').entries)
end
output
1) Failure:
test_barcode(TestBooks) [test_books.rb:24]:
<#<Books _id: 4da1744c3484173351000001, title: "Turn of a Screw", author: "Henry James", barcode: "666">> expected but was
<#<Books _id: 4da173bd348417333b000001, title: "Turn of a Screw", author: "Henry James", barcode: "666">>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment