Pavlov.Case
Use this module to prepare other modules for testing.
Example
defmodule MySpec do
use Pavlov.Case
it "always passes" do
assert true
end
end
Summary↑
| describe(desc, \\ {:_, [], Pavlov.Case}, pending \\ false, contents) | You can nest your tests under a descriptive name. Tests can be infinitely nested |
| it(desc, var \\ {:_, [], Pavlov.Case}, contents) | The cornerstone BDD macro, “it” allows your test to be defined via a string |
| let(name, contents) | Allows lazy initialization of subjects for your tests. Subjects created via “let” will never leak into other contexts (defined via “describe” or “context”), not even those who are children of the context where the lazy subject is defined |
| subject(contents) | You can use |
| xdescribe(desc, \\ {:_, [], Pavlov.Case}, contents) | Defines a group of tests as pending. Any other contexts nested within an xdescribe will not run as well |
| xit(description, var \\ {:_, [], Pavlov.Case}, contents) | Allows you specify a pending test, meaning that it is never run |
Macros
You can nest your tests under a descriptive name. Tests can be infinitely nested.
The cornerstone BDD macro, “it” allows your test to be defined via a string.
Example
it "is the truth" do
assert true == true
end
Allows lazy initialization of subjects for your tests. Subjects created via “let” will never leak into other contexts (defined via “describe” or “context”), not even those who are children of the context where the lazy subject is defined.
Example:
let :lazy do
"oh so lazy"
end
it "lazy initializes" do
assert lazy == "oh so lazy"
end
You can use subject to explicitly define the value
that is returned by the subject method in the example
scope. A subject declared in a context will be available
in child contexts as well.
Example:
describe "Array" do
subject do
[1, 2, 3]
end
it "has the prescribed elements" do
assert subject == [1, 2, 3]
end
context "Inner context" do
it "can use an outer-scope subject" do
assert subject == [1, 2, 3]
end
end
end
Defines a group of tests as pending. Any other contexts nested within an xdescribe will not run as well.
Allows you specify a pending test, meaning that it is never run.
Example
xit "is the truth" do
# This will never run
assert true == true
end