Skip to content

Instantly share code, notes, and snippets.

@sritchie
Forked from sorenmacbeth/kwphrase_tests.clj
Created January 26, 2012 22:53
Show Gist options
  • Save sritchie/1685634 to your computer and use it in GitHub Desktop.
Save sritchie/1685634 to your computer and use it in GitHub Desktop.
(ns ybot.kwphrase-tests
(:use [ybot.analytics.ga kwphrase]
[ybot datastores]
[midje sweet cascalog]))
(let [ga-data [["20121025"
"http://dopeness.org"
"United States"
"Oregon"
"Portland"
"filtered"
"google"
"5"
"2"
"2"
"true"
"2"
"0"]
["20121025"
"http://dopeness.org"
"United States"
"Oregon"
"Portland"
"passed"
"google"
"8"
"4"
"4"
"true"
"4"
"0"]]
ngram-data [["filtered" "filtered"]
["passed" "passed"]]]
(fact
(landings-by-ngram (gadata-tap :ga-tap) (ngram-generator :ngram-gen) 3)
=not=> (produces-some [["filtered" 2 5 2 2 0 100.0 100.0 0 2.5]])
(provided
(gadata-tap :ga-tap) => ga-data
(ngram-generator :ngram-gen) => ngram-data)))
;; or
(fact
(landings-by-ngram ga-data ngram-data 3)
=not=> (produces-some [["filtered" 2 5 2 2 0 100.0 100.0 0 2.5]]))
@AlexBaranosky
Copy link

I like the second option, myself.

@sritchie
Copy link
Author

Me too! This was a fork showing that rather than mocking a generator, you can pass a data structure in directly. I'm loving this.

@AlexBaranosky
Copy link

An unrelated but very cool feature is folded fakes: https://github.com/marick/Midje/wiki/Folded-prerequisites

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment