This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HOW TO USE | |
| ========== | |
| COMMAND LINE | |
| ============= | |
| spec --color --format specdoc user.rspec | |
| RAILS | |
| ============= | |
| ./script/generate rspec_model User |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # RSpec 2.0 syntax Cheet Sheet | |
| # Задаем спек внутри модуля Игрок, рспек автоматически подхватит Player::MovieList как переменную 'subject' (смотри ниже) | |
| module Player | |
| describe MovieList, "с необязательным описанием" do | |
| it "этот пример находится в ожидании(pending) поэтому можно написать его побырому" | |
| it "это уже рабочий пример, но он не будет красным а желтым, потому что мы его замарозим" do | |
| pending("пендинг все обрывает, но не помечает красным") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| rspec_shoulda: | | |
| Shoulda Rspec Matchers | |
| For more information on rspec, rspec-rails, shoulda | |
| $ cheat rspec | |
| $ cheat rspec_on_rails_matchers | |
| $ cheat shoulda | |
| Models Matchers | |
| Data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Stumbling towards Y (Clojure Version) | |
| ; | |
| ; (this tutorial can be cut & pasted into your IDE / editor) | |
| ; | |
| ; The applicative-order Y combinator is a function that allows one to create a | |
| ; recursive function without using define. | |
| ; This may seem strange, because usually a recursive function has to call | |
| ; itself, and thus relies on itself having been defined. | |
| ; | |
| ; Regardless, here we will stumble towards the implementation of the Y combinator. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; A Simplifier for all Expressions | |
| ;; Example: | |
| ;; (simplify '(* 1 (+ x (- y y)))) ;=> x | |
| ;; (simplify '(and a (and (and) b))) ;=> (and a b) | |
| ;; See section 4.4, "Syntactic Abstraction" of Norvig and Pitman's | |
| ;; "Tutorial on Good Lisp Programming Style": | |
| ;; http://norvig.com/luv-slides.ps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;----------------------------------------------------------------------------------- | |
| ; 1 - example of simple operations | |
| ;----------------------------------------------------------------------------------- | |
| ; arithmatic operations | |
| (+ 1 2) | |
| (* 2 3) | |
| (/ 8 2) | |
| (> 4 3) | |
| (= 4 6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For each Ruby module/class, we have Ruby methods on the left and the equivalent | |
| Clojure functions and/or relevant notes are on the right. | |
| For clojure functions, symbols indicate existing method definitions, in the | |
| clojure namespace if none is explicitly given. clojure.contrib.*/* functions can | |
| be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master, | |
| ruby-to-clojure.*/* functions can be obtained from the source files in this | |
| gist. | |
| If no method symbol is given, we use the following notation: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns sunil.curry) | |
| (defn partial+ | |
| "Takes a function f and fewer than the normal arguments to f, and | |
| returns a fn that takes a variable number of additional args. When | |
| called, the returned function calls f with args + additional args. | |
| differs from the core version in that it works on just one argument." | |
| {:added "1.0"} | |
| ([f] f) | |
| ([f arg1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defmacro def-curry-fn [name args & body] | |
| {:pre [(not-any? #{'&} args)]} | |
| (if (empty? args) | |
| `(defn ~name ~args ~@body) | |
| (let [rec-funcs (reduce (fn [l v] | |
| `(letfn [(helper# | |
| ([] helper#) | |
| ([x#] (let [~v x#] ~l)) | |
| ([x# & rest#] (let [~v x#] | |
| (apply (helper# x#) rest#))))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Example implementation of Norvig's Spellchecker in Clojure, | |
| ;; using core.async | |
| ;; | |
| ;; There are probably some bugs in this. | |
| ;; | |
| ;; Original problem: https://github.com/ericnormand/spelling-jam | |
| ;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/ | |
| ;; | |
| ;; Clojure core.async introduction: | |
| ;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html |