Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests for seach module

  • Loading branch information...
commit e9e542e5377c567a037e18031ac6178552b9efd0 1 parent c34bf78
@john-griffin authored
Showing with 19 additions and 3 deletions.
  1. +3 −3 README.md
  2. +16 −0 spec/models/bookmark_spec.rb
View
6 README.md
@@ -1,9 +1,9 @@
# bookmarker
-A basic bookmarking web app. Supports:
+A clean Rails bookmarking app. Supports:
+* Bookmark search
* Organisation of bookmarks by site
* Title retrieval
* Bit.ly short URL generation
-* Tagging of bookmarks
-
+* Tagging of bookmarks
View
16 spec/models/bookmark_spec.rb
@@ -10,4 +10,20 @@
it "should create a new instance given valid attributes" do
Bookmark.create!(@valid_attributes)
end
+
+ it "empty search should return nothing" do
+ assert_equal([], Bookmark.search("", ["title", "url"]))
+ assert_equal([], Bookmark.search(nil, ["title", "url"]))
+ end
+
+ it "searching should bring results back against all fields passed in" do
+ bookmark1 = Bookmark.create!(:url => "http://www.apple.com/ipad/")
+ bookmark2 = Bookmark.create!(:url => "http://www.macrumors.com/2010/03/01/ipad-supplies-to-be-constrained-at-launch-due-to-production-issues/")
+ bookmark3 = Bookmark.create!(:url => "http://www.bbc.co.uk/iplayer/")
+ results = Bookmark.search("ipad", ["title", "url"])
+ assert_equal(true, results.include?(bookmark1))
+ assert_equal(true, results.include?(bookmark2))
+ assert_equal(false, results.include?(bookmark3))
+ assert_equal(2, results.length)
+ end
end

0 comments on commit e9e542e

Please sign in to comment.
Something went wrong with that request. Please try again.