Skip to content

Instantly share code, notes, and snippets.

View donbonifacio's full-sized avatar
🚀
Building platforms

Pedro Pereira Santos donbonifacio

🚀
Building platforms
View GitHub Profile
//top of steps file or in seperate factory file
require 'factory_girl'
Factory.define :user do |u|
u.login 'the_login'
u.email '[email protected]'
u.password 'password'
u.password_confirmation 'password'
# u.activated_at 'active'
end
class Updater
def self.update_total_points(employee)
employee.total_points = employee.rocket_actions.sum(:points)
gateway.persist_employee_total(employee)
end
def gateway
if defined? Rails
rails gateway
<?xml version="1.0" encoding="UTF-8"?>
<shipping>
<date>19/12/2013</date>
<due_date>19/12/2013</due_date>
<loaded_at>10/10/2050</loaded_at>
<license_plate>00-AA-11</license_plate>
<client>
<name>Joao</name>
<code>Jony123</code>
<email>[email protected]</email>
@donbonifacio
donbonifacio / gist:560ffc4afa6b3a883d5d
Created April 17, 2015 09:38
Common gateway usage
(defn save!
"Persists an account"
[account]
(common/gateway-call :account-gateway :save! account))
(defn find-by-id
"Find account by given id"
[id]
(common/gateway-call :account-gateway :find-by-id id))
(defn gateway-fn
"Retrieves a function given it's full name"
[gateway access method]
{:post [(not (nil? %))]}
(let [sym (symbol (str "project-namespace." (name gateway) "." (name access) "/" (name method)))]
(resolve sym)))
(defn gateway-call
"Dispatches to a function on the given provider"
[access method & args]
@donbonifacio
donbonifacio / gist:b48f992b461d6bb321eb
Last active August 29, 2015 14:19
Mongo gateway implementation
(defn save!
"Persists an account"
[account]
(-> (common/db)
(mc/save-and-return "accounts" account)))
(defn find-by-id
"Find account by given query"
[id]
(-> (common/db)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Clojure Common 84 682 6 4425
Clojure 1 3 0 13
ClojureScript 1 5 0 10
-------------------------------------------------------------------------------
SUM: 86 690 6 4448
-------------------------------------------------------------------------------
lein with-profile clj run
lein with-profile cljs-node cljsbuild test
lein with-profile cljs-browser cljsbuild test
(ns obb-rules.action-test
(:require
#?(:clj [clojure.test :refer [deftest testing is run-tests]]
:cljs [cljs.test :refer-macros [deftest testing is run-tests]])))
(ns obb-rules.evaluator-test
(:require
#?(:cljs [cljs.test.check :as tc])
#?(:clj [clojure.test.check.generators :as gen]
:cljs [cljs.test.check.generators :as gen])
#?(:clj [clojure.test.check.properties :as prop]
:cljs [cljs.test.check.properties :as prop :include-macros true])
#?(:clj [clojure.test.check.clojure-test :refer [defspec]]
:cljs [cljs.test.check.cljs-test :refer-macros [defspec]])
#?(:clj [clojure.test :refer [deftest testing is run-tests]]