Liking cljdoc? Tell your friends :D

midje.repl

Functions useful when using Midje in the repl or from the command line. See midje-repl-help for details.

Functions useful when using Midje in the repl or from the command line.
See `midje-repl-help` for details.
raw docstring

&clj

This var is defined so that Midje prerequisites can use & for optional args without having to quote it.

This var is defined so that Midje prerequisites can use & for optional args without having to quote it.
sourceraw docstring

*include-midje-checks*clj

This variable is defunct. Use include-midje-checks instead.

This variable is defunct. Use `include-midje-checks` instead.
sourceraw docstring

*meclj

Stores last exception encountered in autotesting

Stores last exception encountered in autotesting
sourceraw docstring

=>clj

As a checking arrow: the left side should result in the right side. As a prerequisite arrow: the fake should return the thing on the right.

As a checking arrow: the left side should result in the right side.
As a prerequisite arrow: the fake should return the thing on the right.
sourceraw docstring

=contains=>clj

Data prerequisite arrow. Ex. (fact (:a ..m..) => 1 (provided ..m.. =contains=> {:a 1}))

Data prerequisite arrow.
Ex. (fact
      (:a ..m..) => 1
      (provided ..m.. =contains=> {:a 1}))
sourceraw docstring

=deny=>clj

Checking arrow. The left side should NOT result in the right side.

Checking arrow. The left side should NOT result in the right side.
sourceraw docstring

=expands-to=>clj

Checking arrow. The left side should macroexpand-1 to the right side.

Checking arrow. The left side should macroexpand-1 to the right side.
sourceraw docstring

=future=>clj

Checking arrow. The check won't evaluate, but will leave a 'WORK TO DO' reminder in the report.

Checking arrow. The check won't evaluate, but will
leave a 'WORK TO DO' reminder in the report.
sourceraw docstring

=not=>clj

Checking arrow. The left side should NOT result in the right side.

Checking arrow. The left side should NOT result in the right side.
sourceraw docstring

=streams=>clj

Prerequisite arrow. The fake will return the first element of the given sequence the first time the fake is evaluated, the second element the second time, and so on. Note, that each element is only evaluated when needed, thus in the below example the exception is never thrown.

Ex. (def tally [] (+ (bar) (bar) (bar))) (fact (tally) => 6 (provided (bar) =streams=> [1 2 3 (throw (Exception.))]))

Prerequisite arrow. The fake will return the first element
of the given sequence the first time the fake is evaluated, the second
element the second time, and so on. Note, that each element is only
evaluated when needed, thus in the below example the exception is
never thrown.

Ex. (def tally [] (+ (bar) (bar) (bar)))
    (fact (tally) => 6
      (provided (bar) =streams=> [1 2 3 (throw (Exception.))]))
sourceraw docstring

=test=>clj

Use this when testing Midje code that processes arrow-forms

Use this when testing Midje code that processes arrow-forms
sourceraw docstring

=throw-parse-exception=>clj

Use this to generate an exception while parsing

Use this to generate an exception while parsing
sourceraw docstring

=throws=>clj

Prerequisite arrow. The fake will throw the Throwable on the right side of the arrow.

Ex. (def f [] (g)) (fact (f) => (throws IllegalArgumentException. "boom") (provided (g) =throws=> (IllegalArgumentException. "boom")))

Prerequisite arrow. The fake will throw the Throwable on
the right side of the arrow.

Ex. (def f [] (g))
    (fact (f) => (throws IllegalArgumentException. "boom")
      (provided (g) =throws=> (IllegalArgumentException. "boom")))
sourceraw docstring

add-midje-fact-symbolsclj

(add-midje-fact-symbols symbols)

If you use a macro to wrap Midje's fact forms, with-state-changes will complain that it contains no facts. You can avoid that by "registering" your macro with Midje.

If you use a macro to wrap Midje's fact forms, `with-state-changes` will
complain that it contains no facts. You can avoid that by "registering"
your macro with Midje.
sourceraw docstring

aftercljmacro

(after _wrapping-target_ after-form)

Code to run after a given wrapping target (:facts, :contents, :checks). Used with background and against-background

Code to run after a given wrapping target (:facts, :contents, :checks).
Used with background and against-background
sourceraw docstring

against-backgroundcljmacro

(against-background background-forms & foreground-forms)

Puts a series of background changers into effect until the end of the against-background scope. They remain in effect when a loaded fact is rechecked (as with midje.repl/recheck-fact).

See (doc midje-background-changers) for details on background changers.

against-background can be used in two ways. In the first, it has a let-like syntax that wraps a series of facts:

(against-background [(f 33) => 12 (f 34) => 21 (before :facts (reset! some-atom 0))] (fact...) (fact...))

In the second, it can be placed as either the first or last form in a fact, in which case it is taken to "wrap" the entire fact:

(against-background (f 1) => :default, (g 1) => :default)

Note that in this case the square brackets can be omitted.

 Puts a series of *background changers* into effect until the end
of the `against-background` scope. They remain in effect when a
loaded fact is rechecked (as with `midje.repl/recheck-fact`).

See `(doc midje-background-changers)` for details on background
changers.

`against-background` can be used in two ways. In the first, it has
a `let`-like syntax that wraps a series of facts:

   (against-background [(f 33) => 12
                        (f 34) => 21
                        (before :facts (reset! some-atom 0))]
     (fact...)
     (fact...))

In the second, it can be placed as either the first or last form in
a fact, in which case it is taken to "wrap" the entire fact:

  (against-background (f 1) => :default, (g 1) => :default)

Note that in this case the square brackets can be omitted.
sourceraw docstring

antiterminologicaldisintactitudinarian-factcljmacro

(antiterminologicaldisintactitudinarian-fact
  &
  midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

antiterminologicaldisintactitudinarian-factscljmacro

(antiterminologicaldisintactitudinarian-facts
  &
  midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

antiterminologicaldisintactitudinarian-formulacljmacro

(antiterminologicaldisintactitudinarian-formula
  &
  midje.parsing.util.future-variants/forms)

ALPHA/EXPERIMENTAL (subject to change) Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.

ALPHA/EXPERIMENTAL (subject to change)
Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

anythingclj

(anything actual)

Accepts any value.

Accepts any value.
sourceraw docstring

aroundcljmacro

(around _wrapping-target_ around-form)

Code to run around a given wrapping target (:facts, :contents, :checks). Use the symbol '?form' to denote the code that is being wrapped around.

Ex. (around :contents (let [a 999] ?form (print a)))

Used with background and against-background

Code to run around a given wrapping target (:facts, :contents, :checks).
Use the symbol '?form' to denote the code that is being wrapped around.

Ex.
(around :contents (let [a 999]
                    ?form
                    (print a)))

Used with background and against-background
sourceraw docstring

as-checkerclj

(as-checker function)

Label a function as a checker. This is only required if the checker is to be used on the left-hand-side of a prerequisite. See (guide checkers-within-prerequisites). Example:

(fact (f 3) => "odd number received" (provided (g (as-checker odd?)) => "odd number received"))

Label a function as a checker. This is only required if
the checker is to be used on the left-hand-side of a prerequisite.
See `(guide checkers-within-prerequisites)`.
Example:

   (fact (f 3) => "odd number received"
     (provided
       (g (as-checker odd?)) => "odd number received"))
sourceraw docstring

autotestclj

(autotest & args)

autotest checks frequently for changed files. It reloads those files and all files that depend on them. Since test files depend on source files, that typically results in facts being reloaded and checked.

By default, autotest monitors all the files in the project.clj's :source-paths and :test-paths. To change the default, give the :files argument:

(autotest :files "test/midje/util" "src/midje/util") (autotest :files "test/midje/util/t_unify.clj" "src/midje/util/unify.clj")

This is useful in large projects. Note that autotest doesn't follow dependencies outside the given directories. If test/midje/util/A depends on some-untracked-dir/B that depends on src/midje/util/C, a change to C will not cause A to be reloaded.

You can revert back to the project.clj versions like this:

(autotest :all)

You can filter the facts checked by giving more arguments following a :filter or :filters keyword:

(autotest :filter :integration)

Facts matching any of the arguments are the ones that are checked. The arguments can be of these types:

:keyword -- Does the metadata have a truthy value for the keyword? "string" -- Does the fact's name contain the given string? #"regex" -- Does any part of the fact's name match the regex? a function -- Does the function return a truthy value when given the fact's metadata?

autotest can take special keyword arguments:

(autotest :stop) ; stop checking (autotest :pause) ; pause checking (autotest :resume) ; continue after a pause

autotest can also be given an :interval argument to control how often it checks for modified files. The argument is in milliseconds:

(autotest :interval 1000) ; check each second.

The default is to check twice each second.

`autotest` checks frequently for changed files. It reloads those files
and all files that depend on them. Since test files depend on source files,
that typically results in facts being reloaded and checked.

By default, `autotest` monitors all the files in the
project.clj's :source-paths and :test-paths. To change the
default, give the `:files` argument:

   (autotest :files "test/midje/util" "src/midje/util")
   (autotest :files "test/midje/util/t_unify.clj" "src/midje/util/unify.clj")

This is useful in large projects. Note that `autotest` doesn't follow
dependencies outside the given directories. If `test/midje/util/A`
depends on `some-untracked-dir/B` that depends on `src/midje/util/C`,
a change to `C` will not cause `A` to be reloaded.

You can revert back to the project.clj versions like this:

  (autotest :all)

You can filter the facts checked by giving more arguments following
a `:filter` or `:filters` keyword:

  (autotest :filter :integration)

Facts matching any of the arguments are the ones that are
checked. The arguments can be of these types:

:keyword      -- Does the metadata have a truthy value for the keyword?
"string"    -- Does the fact's name contain the given string?
#"regex"    -- Does any part of the fact's name match the regex?
a function    -- Does the function return a truthy value when given
                 the fact's metadata?

`autotest` can take special keyword arguments:

   (autotest :stop)   ; stop checking
   (autotest :pause)  ; pause checking
   (autotest :resume) ; continue after a pause

`autotest` can also be given an `:interval` argument to control how often
it checks for modified files. The argument is in milliseconds:

    (autotest :interval 1000) ; check each second.

The default is to check twice each second.
sourceraw docstring

autotest-default-dirsclj

(autotest-default-dirs)

These are the directories that will be watched if you type autotest with no arguments.

These are the directories that will be watched if you type
`autotest` with no arguments.
sourceraw docstring

autotest-optionsclj

(autotest-options)

If you want a peek at how autotest is controlled, look here.

If you want a peek at how autotest is controlled, look here.
sourceraw docstring

backgroundcljmacro

(background & background-changers)

Puts a series of background changers into effect from the point of execution until the end of the file. They are also in effect when a loaded fact is rechecked (as with midje.repl/recheck-fact).

See (doc midje-background-changers) for details on background changers.

Examples:

(background (f 33) => 12, (f 34) => 21) (background (before :facts (reset! some-atom 0)))

 Puts a series of *background changers* into effect from the point of
execution until the end of the file. They are also in effect when
a loaded fact is rechecked (as with `midje.repl/recheck-fact`).

See `(doc midje-background-changers)` for details on background
changers.

Examples:

   (background (f 33) => 12, (f 34) => 21)
   (background (before :facts (reset! some-atom 0)))
sourceraw docstring

beforecljmacro

(before _wrapping-target_ before-form & {:keys [after]})

Code to run before a given wrapping target (:facts, :contents, :checks). Can take an optional keyword argument :after, for any code to run afterward. Used with background and against-background

Code to run before a given wrapping target (:facts, :contents, :checks).
Can take an optional keyword argument :after, for any code to run afterward.
Used with background and against-background
sourceraw docstring

chatty-checkercljmacro

(chatty-checker [actual-arg] [f & args])

Create a function that returns either true or a description of a failure that shows the value of subexpressions. For example, consider this:

(fact 4 => (fn [actual] (< (h actual) (g actual))))

The failure message only tells you that 4 was a failing value. Contrast to the following:

(fact 4 => (chatty-checker [actual] (< (h actual) (g actual))))

The failure output will contain the value of (h actual) and (g actual).

For more, see (guide chatty-checkers).

Note: if you want your checkers to be and or or expressions, use every-checker or some-checker in preference to chatty-checker.

Create a function that returns either true or a description of a failure
 that shows the value of subexpressions. For example, consider this:

   (fact 4 => (fn [actual] (< (h actual) (g actual))))

The failure message only tells you that 4 was a failing value. Contrast
to the following:

   (fact 4 => (chatty-checker [actual] (< (h actual) (g actual))))

The failure output will contain the value of (h actual) and (g actual).

For more, see `(guide chatty-checkers)`.

Note: if you want your checkers to be `and` or `or` expressions, use
`every-checker` or `some-checker` in preference to `chatty-checker`.
sourceraw docstring

check-factsclj

(check-facts & args__11281__auto__)

Check facts that have already been defined.

(check-facts ns midje.t-repl) -- defined in named namespaces (check-facts :all) -- defined anywhere (check-facts) -- check same facts again

You can further filter the facts by giving more arguments. Facts matching any of the arguments are the ones that are checked. The arguments are:

:keyword -- Does the metadata have a truthy value for the keyword? "string" -- Does the fact's name contain the given string? #"regex" -- Does any part of the fact's name match the regex? a function -- Does the function return a truthy value when given the fact's metadata?

In addition, you can adjust what's printed. See (doc midje-print-levels).

If the call doesn't mention any namespaces, the ones from the previous load-facts, check-facts, or fetch-facts are reused. The filters and print-levels are also reused, unless they're overridden with explicit arguments.

Check facts that have already been defined.

(check-facts *ns* midje.t-repl) -- defined in named namespaces
(check-facts :all)              -- defined anywhere
(check-facts)                   -- check same facts again

You can further filter the facts by giving more arguments. Facts matching
any of the arguments are the ones that are checked. The arguments are:

:keyword      -- Does the metadata have a truthy value for the keyword?
"string"    -- Does the fact's name contain the given string?
#"regex"    -- Does any part of the fact's name match the regex?
a function    -- Does the function return a truthy value when given
                 the fact's metadata?

In addition, you can adjust what's printed. See `(doc midje-print-levels)`.

If the call doesn't mention any namespaces, the ones from the
previous `load-facts`, `check-facts`, or `fetch-facts` are
reused. The filters and print-levels are also reused, unless
they're overridden with explicit arguments.
sourceraw docstring

check-one-factclj

Check a single fact. Takes as its argument a function such as is returned by last-fact-checked.

Check a single fact. Takes as its argument a function such
as is returned by `last-fact-checked`.
sourceraw docstring

checkercljmacro

(checker args & body)

Creates an anonymous function tagged as a checker. Such tagging is only needed if the checker is to be used on the left-hand-side of a prerequisite. See (guide checkers-within-prerequisites). Example: (provided (f (checker [x] (and (pos? x) (even? x)))) => 3)

Creates an anonymous function tagged as a checker. Such tagging is only
needed if the checker is to be used on the left-hand-side of a
prerequisite.  See `(guide checkers-within-prerequisites)`.
Example:
    (provided
       (f (checker [x] (and (pos? x) (even? x)))) => 3)
sourceraw docstring

containsclj

(contains expected)
(contains expected looseness)

Checks that the expected result is a subsequence of the actual result:

To succeed, f's result must be (1) contiguous and (2) in the same order as in the contains clause. Here are examples:

[3 4 5 700] => (contains [4 5 700]) ; true [4 700 5] => (contains [4 5 700]) ; false [4 5 'hi 700] => (contains [4 5 700]) ; false

The :in-any-order modifier loosens the second requirement:

['hi 700 5 4] => (contains [4 5 700] :in-any-order) ; true [4 5 'hi 700] => (contains [4 5 700] :in-any-order) ; false b/c 'hi is in middle

The :gaps-ok modifier loosens the first:

[4 5 'hi 700] => (contains [4 5 700] :gaps-ok) ; true [4 700 'hi' 5] => (contains [4 5 700] :gaps-ok) ; false b/c of bad order

The two modifiers can be used at the same time:

[4 700 5] => (contains [4 5 700] :gaps-ok :in-any-order) ; true [4 5 'hi 700] => (contains [4 5 700] :in-any-order :gaps-ok) ; true [700 'hi 4 5 'hi] => (contains [4 5 700] :in-any-order :gaps-ok) ; true

Another way to indicate :in-any-order is to describe what's contained by a set. The following two are equivalent:

[700 4 5] => (contains [4 5 700] :in-any-order) [700 4 5] => (contains #{4 5 700})

:gaps-ok can be used with a set. (So can :in-any-order, but it has no effect.)

Checks that the expected result is a subsequence of the actual result:

To succeed, f's result must be (1) contiguous and (2) in the
same order as in the contains clause. Here are examples:

   [3 4 5 700]   => (contains [4 5 700]) ; true
   [4 700 5]     => (contains [4 5 700]) ; false
   [4 5 'hi 700] => (contains [4 5 700]) ; false

The :in-any-order modifier loosens the second requirement:

   ['hi 700 5 4] => (contains [4 5 700] :in-any-order) ; true
   [4 5 'hi 700] => (contains [4 5 700] :in-any-order) ; false b/c 'hi is in middle

The :gaps-ok modifier loosens the first:

   [4 5 'hi 700]  => (contains [4 5 700] :gaps-ok) ; true
   [4 700 'hi' 5] => (contains [4 5 700] :gaps-ok) ; false b/c of bad order

The two modifiers can be used at the same time:

   [4 700 5]         => (contains [4 5 700] :gaps-ok :in-any-order) ; true
   [4 5 'hi 700]     => (contains [4 5 700] :in-any-order :gaps-ok) ; true
   [700 'hi 4 5 'hi] => (contains [4 5 700] :in-any-order :gaps-ok) ; true

Another way to indicate :in-any-order is to describe
what's contained by a set. The following two are equivalent:

   [700 4 5] => (contains [4 5 700] :in-any-order)
   [700 4 5] => (contains #{4 5 700})

:gaps-ok can be used with a set. (So can :in-any-order, but it has no effect.)
sourceraw docstring

defcheckercljmacro

(defchecker name docstring? attr-map? bindings+bodies)

Like defn, but tags the variable created and the function it refers to as checkers. This is only required if the checker is to be used in the left-hand side of a prerequisite, but it never hurts to define checkers using this. Here is a checker for positive even numbers:

(defchecker twosie [actual]
   (and (pos? actual) (even? actual)))
(fact 2 => twosie)

Here is the definition of a simple version of the roughly checker:

(defchecker roughly [expected delta] (checker [actual] (and (number? actual) ...))) (fact 1.1 => (roughly 1 0.2))

See also (doc chatty-checker).

Like defn, but tags the variable created and the function it
refers to as checkers. This is only required if the checker is
to be used in the left-hand side of a prerequisite, but it never
hurts to define checkers using this. Here is a checker for
positive even numbers:

    (defchecker twosie [actual]
       (and (pos? actual) (even? actual)))
    (fact 2 => twosie)

 Here is the definition of a simple version of the `roughly`
 checker:

   (defchecker roughly [expected delta]
      (checker [actual]
         (and (number? actual)
              ...)))
  (fact 1.1 => (roughly 1 0.2))

 See also `(doc chatty-checker)`.
sourceraw docstring

eight-ofclj

(eight-of expected)

Checks whether a sequence contains precisely eight results, and that they each match the checker.

Ex. (fact [:a :a :a :a :a :a :a :a] => (eight-of :a))

Checks whether a sequence contains precisely eight results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a :a :a :a :a] => (eight-of :a))
sourceraw docstring

every-checkercljmacro

(every-checker & checker-forms)

Combines multiple checkers into one checker that passes when all component checkers pass. If one checker fails, the remainder are not run. The output shows which checker failed.

Example:

(fact 3 => (every-checker odd? neg?))
FAIL ...
...
During checking, these intermediate values were seen:
   neg? => false

The combined checkers can include anything that can appear on the right-hand side of an arrow.

Example:

(fact "-1b-" => (every-checker #(= 4 (count %))
                               #"1b"))
Combines multiple checkers into one checker that passes
when all component checkers pass. If one checker fails,
the remainder are not run. The output shows which checker
failed.

Example:

    (fact 3 => (every-checker odd? neg?))
    FAIL ...
    ...
    During checking, these intermediate values were seen:
       neg? => false

The combined checkers can include anything that can appear on the
right-hand side of an arrow.

Example:

    (fact "-1b-" => (every-checker #(= 4 (count %))
                                   #"1b"))
sourceraw docstring

exactlyclj

(exactly expected)

Checks for equality. Use to avoid default handling of functions.

Checks for equality. Use to avoid default handling of functions.
sourceraw docstring

factcljmacro

(fact & _)

A fact is a statement about code:

(fact "one plus one is two" (+ 1 1) => 2)

Facts may describe one functions dependency on another:

(fact (f ..x..) => 12 (provided (g ..x..) => 6))

A fact is a statement about code:

(fact "one plus one is two"
  (+ 1 1) => 2)

Facts may describe one functions dependency on another:

(fact
  (f ..x..) => 12
  (provided (g ..x..) => 6))
sourceraw docstring

fact-descriptionclj

(fact-description fact)

Return the description of the given fact. Facts are in the form returned by fetch-facts.

Return the description of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-fileclj

(fact-file fact)

Return the file of the given fact. Facts are in the form returned by fetch-facts.

Return the file of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-groupcljmacro

(fact-group & forms)

Supply default metadata to all facts in the body.

Supply default metadata to all facts in the body.
sourceraw docstring

fact-guidclj

(fact-guid fact)

Return the guid of the given fact. Facts are in the form returned by fetch-facts.

Return the guid of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-lineclj

(fact-line fact)

Return the line of the given fact. Facts are in the form returned by fetch-facts.

Return the line of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-nameclj

(fact-name fact)

Return the name of the given fact. Facts are in the form returned by fetch-facts.

Return the name of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-namespaceclj

(fact-namespace fact)

Return the namespace of the given fact. Facts are in the form returned by fetch-facts.

Return the namespace of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-sourceclj

(fact-source fact)

Return the source of the given fact. Facts are in the form returned by fetch-facts.

Return the source of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

fact-top-level?clj

(fact-top-level? fact)

Return the top-level? of the given fact. Facts are in the form returned by fetch-facts.

Return the top-level? of the given fact.
Facts are in the form returned by `fetch-facts`.
sourceraw docstring

factscljmacro

(facts & forms)

Alias for fact.

Alias for fact.
sourceraw docstring

FALSEYclj

(FALSEY actual)

Returns precisely true if actual is nil or false.

Returns precisely true if actual is nil or false.
sourceraw docstring

falseyclj

(falsey actual)

Returns precisely true if actual is nil or false.

Returns precisely true if actual is nil or false.
sourceraw docstring

fetch-factsclj

(fetch-facts & args__11281__auto__)

Fetch facts that have already been defined, whether by loading them from a file or via the repl.

(fetch-facts ns 'midje.t-repl) -- facts defined in these namespaces (fetch-facts :all) -- all known facts (fetch-facts) -- reuse previous arguments

You can further filter the facts by giving more arguments. Facts matching any of the arguments are included in the result. The arguments are:

:keyword -- Does the metadata have a truthy value for the keyword? "string" -- Does the fact's name contain the given string? #"regex" -- Does any part of the fact's name match the regex? a function -- Does the function return a truthy value when given the fact's metadata?

If the call doesn't mention any namespaces, the ones from the previous load-facts, check-facts, or fetch-facts are reused. The filters are also reused, unless they're overridden with explicit arguments.

Fetch facts that have already been defined, whether by loading
them from a file or via the repl.

(fetch-facts *ns* 'midje.t-repl)  -- facts defined in these namespaces
(fetch-facts :all)                -- all known facts
(fetch-facts)                     -- reuse previous arguments

You can further filter the facts by giving more arguments. Facts matching
any of the arguments are included in the result. The arguments are:

:keyword      -- Does the metadata have a truthy value for the keyword?
"string"    -- Does the fact's name contain the given string?
#"regex"    -- Does any part of the fact's name match the regex?
a function    -- Does the function return a truthy value when given
                 the fact's metadata?

If the call doesn't mention any namespaces, the ones from the
previous `load-facts`, `check-facts`, or `fetch-facts` are
reused. The filters are also reused, unless they're overridden
with explicit arguments.
sourceraw docstring

five-ofclj

(five-of expected)

Checks whether a sequence contains precisely five results, and that they each match the checker.

Ex. (fact [:a :a :a :a :a] => (five-of :a))

Checks whether a sequence contains precisely five results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a :a] => (five-of :a))
sourceraw docstring

forget-factsclj

(forget-facts & args__11281__auto__)

Forget defined facts so that they will not be found by check-facts or fetch-facts.

(forget-facts ns midje.t-repl -- defined in named namespaces (forget-facts :all) -- defined anywhere (forget-facts) -- forget facts worked on by most recent check-facts, load-facts, or fetch-facts.

You can further filter the facts by giving more arguments. Facts matching any of the arguments are the ones that are forgotten. The arguments are:

:keyword -- Does the metadata have a truthy value for the keyword? "string" -- Does the fact's name contain the given string? #"regex" -- Does any part of the fact's name match the regex? a function -- Does the function return a truthy value when given the fact's metadata?

Filters from the previous command are reused unless they're overridden.

Forget defined facts so that they will not be found by `check-facts`
or `fetch-facts`.

(forget-facts *ns* midje.t-repl -- defined in named namespaces
(forget-facts :all)             -- defined anywhere
(forget-facts)                  -- forget facts worked on by most
                                   recent `check-facts`, `load-facts`,
                                   or `fetch-facts`.

You can further filter the facts by giving more arguments. Facts matching
any of the arguments are the ones that are forgotten. The arguments are:

:keyword      -- Does the metadata have a truthy value for the keyword?
"string"    -- Does the fact's name contain the given string?
#"regex"    -- Does any part of the fact's name match the regex?
a function    -- Does the function return a truthy value when given
                 the fact's metadata?

Filters from the previous command are reused unless they're overridden.
sourceraw docstring

formulacljmacro

(formula docstring? opts-map? bindings & body)

Generative-style fact macro.

Ex. (formula "any two strings concatenated begins with the first" [a (gen/string) b (gen/string)] (str a b) => (has-prefix a))

Currently, we recommend you use generators from test.generative.generators.

opts-map keys:

:num-trials - Used to override the number of trials for this formula only. This is higher precedence than num-trials Must be set to a number 1 or greater.

The num-trials dynamic var determines how many facts are generated per formula.

Generative-style fact macro.

Ex. (formula "any two strings concatenated begins with the first"
      [a (gen/string) b (gen/string)]
      (str a b) => (has-prefix a))

Currently, we recommend you use generators from test.generative.generators.

opts-map keys:

   :num-trials - Used to override the number of trials for this formula only.
                 This is higher precedence than *num-trials*
                 Must be set to a number 1 or greater.

The *num-trials* dynamic var determines
how many facts are generated per formula.
sourceraw docstring

four-ofclj

(four-of expected)

Checks whether a sequence contains precisely four results, and that they each match the checker.

Ex. (fact [:a :a :a :a] => (four-of :a))

Checks whether a sequence contains precisely four results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a] => (four-of :a))
sourceraw docstring

future-factcljmacro

(future-fact & midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

future-factscljmacro

(future-facts & midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

future-formulacljmacro

(future-formula & midje.parsing.util.future-variants/forms)

ALPHA/EXPERIMENTAL (subject to change) Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.

ALPHA/EXPERIMENTAL (subject to change)
Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

guideclj

source

hasclj

(has quantifier predicate)

You can apply Clojure's quantification functions (every?, some, and so on) to all the values of sequence.

Ex. (fact (f) => (has every? odd?))

You can apply Clojure's quantification functions (every?, some, and so on)
to all the values of sequence.

Ex. (fact (f) => (has every? odd?))
sourceraw docstring

has-prefixclj

(has-prefix expected-prefix)
(has-prefix expected-prefix looseness?)

Checks that the actual result starts with the expected result:

[1 2 3] => (has-prefix [1 2]) ; true [1 2 3] => (has-prefix [2 1]) ; false - order matters [1 2 3] => (has-prefix [2 1] :in-any-order) ; true [1 2 3] => (has-prefix #{2 1}) ; true

Checks that the actual result starts with the expected result:

[1 2 3] => (has-prefix   [1 2]) ; true
[1 2 3] => (has-prefix   [2 1]) ; false - order matters
[1 2 3] => (has-prefix   [2 1] :in-any-order) ; true
[1 2 3] => (has-prefix  #{2 1}) ; true 
sourceraw docstring

has-suffixclj

(has-suffix expected-suffix)
(has-suffix expected-suffix looseness?)

Checks that the actual result ends with the expected result:

[1 2 3] => (has-suffix [2 3]) ; true [1 2 3] => (has-suffix [3 2]) ; false - order matters [1 2 3] => (has-suffix [3 2] :in-any-order) ; true [1 2 3] => (has-suffix #{3 2}) ; true

Checks that the actual result ends with the expected result:

[1 2 3] => (has-suffix   [2 3]) ; true
[1 2 3] => (has-suffix   [3 2]) ; false - order matters
[1 2 3] => (has-suffix   [3 2] :in-any-order) ; true
[1 2 3] => (has-suffix  #{3 2}) ; true 
sourceraw docstring

incipient-factcljmacro

(incipient-fact & midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

incipient-factscljmacro

(incipient-facts & midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

incipient-formulacljmacro

(incipient-formula & midje.parsing.util.future-variants/forms)

ALPHA/EXPERIMENTAL (subject to change) Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.

ALPHA/EXPERIMENTAL (subject to change)
Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

include-midje-checksclj

True by default. If set to false, Midje checks are not included into production code, whether compiled or loaded.

Note that the variable must be set, as with alter-var-root or def, not bound, as with binding.

True by default. If set to false, Midje checks are not
included into production code, whether compiled or loaded.

Note that the variable must be set, as with `alter-var-root`
or `def`, not bound, as with `binding`.
sourceraw docstring

irrelevantclj

(irrelevant actual)

Accepts any value.

Accepts any value.
sourceraw docstring

justclj

(just expected)
(just expected looseness)

A variant of contains, just, will fail if the left-hand-side contains any extra values: [1 2 3] => (just [1 2 3]) ; true [1 2 3] => (just [1 2 3 4]) ; false

The first of those seems senseless, since you could just use this:

[1 2 3] => [1 2 3]

However, it's required if you want to use checkers in the expected result:

[1 2 3] => [odd? even? odd?] ; false b/c 2nd-level fns aren't normally treated as checkers. [1 2 3] => (just [odd? even? odd?]) ; true

just is also useful if you don't care about order:

[1 3 2] => (just [1 2 3] :in-any-order) [1 3 2] => (just #{1 2 3})

A variant of contains, just, will fail if the
left-hand-side contains any extra values:
   [1 2 3] => (just [1 2 3])  ; true
   [1 2 3] => (just [1 2 3 4]) ; false

The first of those seems senseless, since you could just use this:

   [1 2 3] => [1 2 3]

However, it's required if you want to use checkers in the expected result:

   [1 2 3] => [odd? even? odd?]  ; false b/c 2nd-level fns aren't normally treated as checkers.
   [1 2 3] => (just [odd? even? odd?]) ; true

just is also useful if you don't care about order:

  [1 3 2] => (just   [1 2 3] :in-any-order)
  [1 3 2] => (just  #{1 2 3})
sourceraw docstring

last-fact-checkedclj

(last-fact-checked)

The last fact or tabular fact that was checked. Only top-level facts are recorded, not facts nested within them.

The last fact or tabular fact that was checked. Only top-level
facts are recorded, not facts nested within them.
sourceraw docstring

load-factsclj

(load-facts & args__11281__auto__)

Load given namespaces, as in: (load-facts 'midje.t-sweet 'midje.t-repl)

A partial namespace ending in a * will load all sub-namespaces. Example: (load-facts 'midje.ideas.*)

If the :all argument is given, all the namespaces in the project.clj's :test-paths and :source-paths will be loaded. But if there's no project.clj, all namespaces under "test" will be loaded.

By default, all facts are loaded from the namespaces. You can, however, add further arguments. Only facts matching one or more of the arguments are loaded. The filter arguments are:

:keyword -- Does the metadata have a truthy value for the keyword? "string" -- Does the fact's name contain the given string? #"regex" -- Does any part of the fact's name match the regex? a function -- Does the function return a truthy value when given the fact's metadata?

In addition, you can adjust what's printed during loading. See (doc midje-print-levels).

If the call doesn't mention any namespaces, the ones from the previous load-facts are reused. The filters and print-levels are also reused, unless they're overridden with explicit arguments.

Load given namespaces, as in:
  (load-facts 'midje.t-sweet 'midje.t-repl)

A partial namespace ending in a `*` will load all sub-namespaces.
Example: (load-facts 'midje.ideas.*)

If the :all argument is given, all the namespaces in the project.clj's
:test-paths and :source-paths will be loaded.
But if there's no project.clj, all namespaces under "test"
will be loaded.

By default, all facts are loaded from the namespaces. You can, however,
add further arguments. Only facts matching one or more of the arguments
are loaded. The filter arguments are:

:keyword      -- Does the metadata have a truthy value for the keyword?
"string"    -- Does the fact's name contain the given string?
#"regex"    -- Does any part of the fact's name match the regex?
a function    -- Does the function return a truthy value when given
                 the fact's metadata?

In addition, you can adjust what's printed during loading.
See `(doc midje-print-levels)`.

If the call doesn't mention any namespaces, the ones from
the previous `load-facts` are reused. The filters and print-levels
are also reused, unless they're overridden with explicit arguments.
sourceraw docstring

metaconstantscljmacro

(metaconstants & symbols)

For a few operations, such as printing and equality checking, the Clojure AOT-compiler becomes confused by Midje's auto-generation of metaconstants. If AOT-compiled tests fail when on-the-fly compiled tests failed, declare your metaconstants before use. Example: (metaconstants ..m.. ..m.... .mc.)

For a few operations, such as printing and equality checking,
the Clojure AOT-compiler becomes confused by Midje's auto-generation
of metaconstants. If AOT-compiled tests fail when on-the-fly
compiled tests failed, declare your metaconstants before use.
Example:
  (metaconstants ..m.. ..m.... .mc.)
sourceraw docstring

midjeclj

source

midje-arrowsclj

source

midje-checkersclj

source

midje-configurationclj

source

midje-defining-checkersclj

source

midje-factclj

source

midje-factsclj

source

midje-prerequisitesclj

source

midje-print-levelclj

source

midje-print-levelsclj

source

midje-replclj

source

midje-setupclj

source

midje-teardownclj

source

n-ofclj

(n-of expected expected-count)

Checks whether a sequence contains precisely n results, and that they each match the checker.

Ex. (fact (repeat 100 :a) => (n-of :a 100))

Checks whether a sequence contains precisely n results, and
 that they each match the checker.

Ex. (fact (repeat 100 :a) => (n-of :a 100))
sourceraw docstring

namespace-state-changescljmacro

(namespace-state-changes & instructions)

Applies arguments to any facts later created in the namespace. Often used in the repl. Example:

(namespace-state-changes (before :facts (reset! state 0))
                         (after :facts (reset! state 1111)))

A later use of namespace-state-changes replaces the effect of an earlier one. To "turn off" a previous use, do this:

(namespace-state-changes)
Applies arguments to any facts later created in the namespace. Often used
in the repl. Example:

    (namespace-state-changes (before :facts (reset! state 0))
                             (after :facts (reset! state 1111)))

A later use of `namespace-state-changes` replaces the effect of an earlier
one. To "turn off" a previous use, do this:

    (namespace-state-changes)
sourceraw docstring

nine-ofclj

(nine-of expected)

Checks whether a sequence contains precisely nine results, and that they each match the checker.

Ex. (fact [:a :a :a :a :a :a :a :a :a] => (nine-of :a))

Checks whether a sequence contains precisely nine results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a :a :a :a :a :a] => (nine-of :a))
sourceraw docstring

one-ofclj

(one-of expected)

Checks whether a sequence contains precisely one result, and that it matches the checker.

Ex. (fact [:a] => (one-of :a))

Checks whether a sequence contains precisely one result, and 
that it matches the checker.

 Ex. (fact [:a] => (one-of :a))
sourceraw docstring

pending-factcljmacro

(pending-fact & midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

pending-factscljmacro

(pending-facts & midje.parsing.util.future-variants/forms)

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.

Fact that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

pending-formulacljmacro

(pending-formula & midje.parsing.util.future-variants/forms)

ALPHA/EXPERIMENTAL (subject to change) Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.

ALPHA/EXPERIMENTAL (subject to change)
Formula that will not be run. Generates 'WORK TO DO' report output as a reminder.
sourceraw docstring

providedclj

A declaration of the provided form

A declaration of the provided form
sourceraw docstring

rcfclj

Synonym for recheck-fact.

Synonym for `recheck-fact`.
sourceraw docstring

recheck-factclj

(recheck-fact)
(recheck-fact print-level)

Recheck the last fact or tabular fact that was checked. When facts are nested, the entire outer-level fact is rechecked. The result is true if the fact checks out.

The optional argument lets you adjust what's printed. See (print-level-help) for legal values.

Recheck the last fact or tabular fact that was checked.
When facts are nested, the entire outer-level fact is rechecked.
The result is true if the fact checks out.

The optional argument lets you adjust what's printed.
See `(print-level-help)` for legal values.
sourceraw docstring

roughlyclj

(roughly expected)
(roughly expected delta)

With two arguments, accepts a value within delta of the expected value. With one argument, the delta is 1/1000th of the expected value.

With two arguments, accepts a value within delta of the
expected value. With one argument, the delta is 1/1000th
of the expected value.
sourceraw docstring

set-autotest-option!clj

(set-autotest-option! key value)

Set autotest options without starting autotesting.

Set autotest options without starting autotesting.
sourceraw docstring

seven-ofclj

(seven-of expected)

Checks whether a sequence contains precisely seven results, and that they each match the checker.

Ex. (fact [:a :a :a :a :a :a :a] => (seven-of :a))

Checks whether a sequence contains precisely seven results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a :a :a :a] => (seven-of :a))
sourceraw docstring

six-ofclj

(six-of expected)

Checks whether a sequence contains precisely six results, and that they each match the checker.

Ex. (fact [:a :a :a :a :a :a] => (six-of :a))

Checks whether a sequence contains precisely six results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a :a :a] => (six-of :a))
sourceraw docstring

some-checkercljmacro

(some-checker & checker-forms)

Combines multiple checkers into one checker that passes when any of the component checkers pass. If one checker passes, the remainder are not run. Example:

(fact 3 => (some-checker even? neg?)) ; fails

The combined checkers can include anything that can appear on the right-hand side of an arrow.

Example:

(fact "-1b-" => (some-checker #(= 4 (count %))
                              "-1b-"))
Combines multiple checkers into one checker that passes
when any of the component checkers pass. If one checker
passes, the remainder are not run. Example:

   (fact 3 => (some-checker even? neg?)) ; fails

The combined checkers can include anything that can appear on the
right-hand side of an arrow.

Example:

    (fact "-1b-" => (some-checker #(= 4 (count %))
                                  "-1b-"))
sourceraw docstring

source-of-last-fact-checkedclj

(source-of-last-fact-checked)

Returns the source of the last fact or tabular fact run.

Returns the source of the last fact or tabular fact run.
sourceraw docstring

tabularcljmacro

(tabular doc-string? fact table)

Generate a table of related facts.

Ex. (tabular "table of simple math" (fact (+ ?a ?b) => ?c)

    ?a ?b      ?c
     1  2       3
     3  4       7
     9 10      19 )
Generate a table of related facts.

Ex. (tabular "table of simple math"
      (fact (+ ?a ?b) => ?c)

        ?a ?b      ?c
         1  2       3
         3  4       7
         9 10      19 )
sourceraw docstring

ten-ofclj

(ten-of expected)

Checks whether a sequence contains precisely ten results, and that they each match the checker.

Ex. (fact [:a :a :a :a :a :a :a :a :a :a] => (ten-of :a))

Checks whether a sequence contains precisely ten results, and 
that they each match the checker.

 Ex. (fact [:a :a :a :a :a :a :a :a :a :a] => (ten-of :a))
sourceraw docstring

three-ofclj

(three-of expected)

Checks whether a sequence contains precisely three results, and that they each match the checker.

Ex. (fact [:a :a :a] => (three-of :a))

Checks whether a sequence contains precisely three results, and 
that they each match the checker.

 Ex. (fact [:a :a :a] => (three-of :a))
sourceraw docstring

throwsclj

(throws & desiderata)

Checks for a thrown Throwable.

The most common cases are: (fact (foo) => (throws IOException) (fact (foo) => (throws IOException #"No such file")

throws takes three kinds of arguments:

  • A class argument requires that the Throwable be of that class.
  • A string or regular expression requires that the message of the Throwable match the argument.
  • A function argument requires that the function, when applied to the Throwable, return a truthy value.

Arguments can be in any order. Except for a class argument, they can be repeated. So, for example, you can write this: (fact (foo) => (throws #"one part" #"another part"))

Checks for a thrown Throwable.

The most common cases are:
    (fact (foo) => (throws IOException)
    (fact (foo) => (throws IOException #"No such file")

`throws` takes three kinds of arguments:
* A class argument requires that the Throwable be of that class.
* A string or regular expression requires that the `message` of the Throwable
  match the argument.
* A function argument requires that the function, when applied to the Throwable,
  return a truthy value.

Arguments can be in any order. Except for a class argument, they can be repeated.
So, for example, you can write this:
    (fact (foo) => (throws #"one part" #"another part"))
sourceraw docstring

TRUTHYclj

(TRUTHY actual)

Returns precisely true if actual is not nil and not false.

Returns precisely true if actual is not nil and not false.
sourceraw docstring

truthyclj

(truthy actual)

Returns precisely true if actual is not nil and not false.

Returns precisely true if actual is not nil and not false.
sourceraw docstring

two-ofclj

(two-of expected)

Checks whether a sequence contains precisely two results, and that they each match the checker.

Ex. (fact [:a :a] => (two-of :a))

Checks whether a sequence contains precisely two results, and 
that they each match the checker.

 Ex. (fact [:a :a] => (two-of :a))
sourceraw docstring

unfinishedcljmacro

(unfinished & names)

Defines a list of names as functions that have no implementation yet. They will throw Errors if ever called.

Defines a list of names as functions that have no implementation yet. They will
throw Errors if ever called.
sourceraw docstring

with-state-changescljmacro

(with-state-changes & forms)

Describe how state should change before or after enclosed facts. Example:

(with-state-changes [(before :facts (reset! state 0)) (after :facts (reset! state 1111))] (fact ...) (fact ...))

Describe how state should change before or after enclosed facts. Example:

(with-state-changes [(before :facts (reset! state 0))
                     (after :facts (reset! state 1111))]
  (fact ...)
  (fact ...))
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close