Skip to content

Commit

Permalink
Switching tests over to midje
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBaranosky committed Feb 17, 2012
1 parent e0caf39 commit 6b02402
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
:description "A library for extracting search query strings for HTTP referrer strings"
:dependencies [[org.clojure/clojure "1.2.1"]]
:dev-dependencies [[lein-midje "1.0.3"]
[midje "1.2.0"]])
[midje "1.3.2-SNAPSHOT"]])

49 changes: 25 additions & 24 deletions test/query_extractor/test/core.clj
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
(ns query-extractor.test.core
(:use [query-extractor.core])
(:use [clojure.test]))
(:use query-extractor.core
midje.sweet))

(tabular "urls with a query to extract"
(fact (extract url) => "a test search")

url
"http://www.bing.com/search?q=a+test+search&go=&qs=n&sk=&sc=1-13&form=QBLH"
"http://www.google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://video.google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://images.google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://www.google.de/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://www.google.co.uk/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://search.yahoo.com/search;_ylt=ArsdL6su1Uh4YCFQvqwY8tCbvZx4?p=a+test+search&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-701"
"http://yandex.com/yandsearch?text=a+test+search&lr=84"
"http://www.ask.com/web?q=a+test+search&search=&qsrc=0&o=0&l=dir"
"http://www.search.com/search?q=a+test+search"
"http://www.baidu.com/s?wd=a+test+search&rsv_bp=0&inputT=5124"
"http://search.aol.com/aol/search?enabled_terms=&s_it=comsearch50&q=a+test+search" )

(deftest test-extract
(let [want "a test search"
tests ["http://www.bing.com/search?q=a+test+search&go=&qs=n&sk=&sc=1-13&form=QBLH"
"http://www.google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://video.google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://images.google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://google.com/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://www.google.de/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://www.google.co.uk/?q=a+test+search&hl=en&biw=1405&bih=783&fp=1&bav=on.2,or.r_gc.r_pw.&cad=b"
"http://search.yahoo.com/search;_ylt=ArsdL6su1Uh4YCFQvqwY8tCbvZx4?p=a+test+search&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-701"
"http://yandex.com/yandsearch?text=a+test+search&lr=84"
"http://www.ask.com/web?q=a+test+search&search=&qsrc=0&o=0&l=dir"
"http://www.search.com/search?q=a+test+search"
"http://www.baidu.com/s?wd=a+test+search&rsv_bp=0&inputT=5124"
"http://search.aol.com/aol/search?enabled_terms=&s_it=comsearch50&q=a+test+search"]]
(doall (map #(is (= want (extract %))) tests))))
(tabular "urls with no query to extract"
(fact (extract url) => nil)

(deftest test-nils
(let [want nil
tests [""
"http://no-params.com"
"http://www.google.com/?x=foo"]]
(doall (map #(is (= want (extract %))) tests))))
url
""
"http://no-params.com"
"http://www.google.com/?x=foo")

0 comments on commit 6b02402

Please sign in to comment.