diff --git a/project.clj b/project.clj index 0cbab66..4ed771d 100644 --- a/project.clj +++ b/project.clj @@ -3,7 +3,8 @@ :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} - :source-paths ["src-clj"] + :source-paths ["src/clj"] + :test-paths ["test/clj"] :dependencies [[org.clojure/clojure "1.5.1"] [http-kit "2.1.8"] [compojure "1.1.5"] @@ -19,7 +20,7 @@ :cljsbuild { :builds [{ ; The path to the top-level ClojureScript source directory: - :source-paths ["src-cljs"] + :source-paths ["src/cljs"] ; The standard ClojureScript compiler options: ; (See the ClojureScript compiler documentation for details.) :compiler { diff --git a/src-clj/grub/async.clj b/src/clj/grub/async.clj similarity index 100% rename from src-clj/grub/async.clj rename to src/clj/grub/async.clj diff --git a/src-clj/grub/core.clj b/src/clj/grub/core.clj similarity index 94% rename from src-clj/grub/core.clj rename to src/clj/grub/core.clj index 80e17ad..5378d6d 100644 --- a/src-clj/grub/core.clj +++ b/src/clj/grub/core.clj @@ -32,7 +32,7 @@ (def app (let [dev? true] (if dev? - (reload/wrap-reload (handler/site #'routes) {:dirs ["src-clj"]}) + (reload/wrap-reload (handler/site #'routes) {:dirs ["src/clj"]}) (handler/site routes)))) (defn -main [& args] diff --git a/src-clj/grub/db.clj b/src/clj/grub/db.clj similarity index 100% rename from src-clj/grub/db.clj rename to src/clj/grub/db.clj diff --git a/src-clj/grub/websocket.clj b/src/clj/grub/websocket.clj similarity index 94% rename from src-clj/grub/websocket.clj rename to src/clj/grub/websocket.clj index a16d799..2d6dc7e 100644 --- a/src-clj/grub/websocket.clj +++ b/src/clj/grub/websocket.clj @@ -25,7 +25,7 @@ (defn push-received-events-to-client [c ws-channel] (go-loop (let [event (! (db/get-incoming-events) event))))) + (>! @db/incoming-events event))))) (defn websocket-handler [request] (httpkit/with-channel request ws-channel diff --git a/src-cljs/grub_client/async-utils.cljs b/src/cljs/grub_client/async-utils.cljs similarity index 100% rename from src-cljs/grub_client/async-utils.cljs rename to src/cljs/grub_client/async-utils.cljs diff --git a/src-cljs/grub_client/core.cljs b/src/cljs/grub_client/core.cljs similarity index 100% rename from src-cljs/grub_client/core.cljs rename to src/cljs/grub_client/core.cljs diff --git a/src-cljs/grub_client/macros.clj b/src/cljs/grub_client/macros.clj similarity index 100% rename from src-cljs/grub_client/macros.clj rename to src/cljs/grub_client/macros.clj diff --git a/src-cljs/grub_client/state.cljs b/src/cljs/grub_client/state.cljs similarity index 100% rename from src-cljs/grub_client/state.cljs rename to src/cljs/grub_client/state.cljs diff --git a/src-cljs/grub_client/view.cljs b/src/cljs/grub_client/view.cljs similarity index 100% rename from src-cljs/grub_client/view.cljs rename to src/cljs/grub_client/view.cljs diff --git a/src-cljs/grub_client/websocket.cljs b/src/cljs/grub_client/websocket.cljs similarity index 93% rename from src-cljs/grub_client/websocket.cljs rename to src/cljs/grub_client/websocket.cljs index be0548d..a599870 100644 --- a/src-cljs/grub_client/websocket.cljs +++ b/src/cljs/grub_client/websocket.cljs @@ -14,6 +14,7 @@ (defn get-remote-events [] (let [out (chan)] (aset @websocket* "onmessage" (fn [event] + (logs "received event" event) (let [grub-event (cljs.reader/read-string (.-data event))] (logs "Received:" grub-event) (go (>! out grub-event))))) diff --git a/test/grub/core_test.clj b/test/clj/grub/core_test.clj similarity index 100% rename from test/grub/core_test.clj rename to test/clj/grub/core_test.clj diff --git a/test/clj/grub/db_test.clj b/test/clj/grub/db_test.clj new file mode 100644 index 0000000..1b544a9 --- /dev/null +++ b/test/clj/grub/db_test.clj @@ -0,0 +1,18 @@ +(ns grub.db-test + (:require [midje.sweet :refer [fact with-state-changes contains anything]] + [monger.collection :as mc] + [grub.db :as db] + [clojure.core.async :refer [>!!]])) + +(def test-db "grub-test") + +(with-state-changes [(before :facts (do (db/connect-and-handle-events test-db) + (mc/drop db/grub-collection)))] + (fact + "Add grub" + (fact "sending an event creates a grub" + (let [test-grub "testgrub" + test-id 12345] + (>!! @db/incoming-events {:event :create :_id test-id :grub test-grub}) + (mc/find-one-as-map db/grub-collection {:_id test-id}) => + {:_id test-id :grub test-grub :completed false})))) diff --git a/test/grub/db_test.clj b/test/grub/db_test.clj deleted file mode 100644 index aaabb79..0000000 --- a/test/grub/db_test.clj +++ /dev/null @@ -1,26 +0,0 @@ -(ns grub.db-test - (:require [midje.sweet :refer [fact with-state-changes contains anything]] - [monger.collection :as mc] - [grub.db :as db] - [clojure.core.async :refer [>!!]])) - -(def test-db "grub-test") - -(with-state-changes [(before :facts (do (mc/drop db/grub-collection) - (db/connect-and-handle-events test-db)))] - (fact - "Add grub" - (fact "sending an event creates a grub" - (let [test-grub "testgrub" - test-id 12345] - (>!! @db/incoming-events {:event :create :_id test-id :grub test-grub}) - (mc/find-one-as-map db/grub-collection {:_id test-id}) => - {:_id test-id :grub test-grub :completed false})) - (fact "missing an id means grub is not created" - (>!! @db/incoming-events {:event :create :grub "testgrub"}) - (mc/find-maps db/grub-collection) => - empty?) - (fact "missing grub text means grub is not created" - (>!! @db/incoming-events {:event :create :_id 12345}) - (mc/find-maps db/grub-collection) => - empty?)))