forked from antonmi/espec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule ESpec.Assert do | ||
@moduledoc """ | ||
Defines `assert` and `refute` helper functions. | ||
""" | ||
|
||
alias ESpec.ExpectTo | ||
alias ESpec.Assertions.Boolean.BeTruthy | ||
alias ESpec.Assertions.Boolean.BeFalsy | ||
|
||
@doc "Calls be_truthy assertion" | ||
def assert(value), do: ExpectTo.to({BeTruthy, []}, {ExpectTo, value}) | ||
|
||
@doc "Calls be_falsy assertion" | ||
def refute(value), do: ExpectTo.to({BeFalsy, []}, {ExpectTo, value}) | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule ESpec.Assertions.Boolean.AssertAndRefuteSpec do | ||
use ESpec, async: true | ||
|
||
context "Success" do | ||
it do: assert 1 | ||
it do: refute nil | ||
end | ||
|
||
xcontext "Errors" do | ||
it do: assert false | ||
it do: refute "a" | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule SomeSpec do | ||
use ESpec | ||
|
||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule Boolean.AssertAndRefuteTest do | ||
use ExUnit.Case, async: true | ||
|
||
defmodule SomeSpec do | ||
use ESpec, async: true | ||
|
||
context "Success" do | ||
it do: ESpec.Assert.assert 1 | ||
it do: ESpec.Assert.refute nil | ||
end | ||
|
||
context "Errors" do | ||
it do: ESpec.Assert.assert false | ||
it do: ESpec.Assert.refute "a" | ||
end | ||
end | ||
|
||
setup_all do | ||
examples = ESpec.Runner.run_examples(SomeSpec.examples) | ||
{ :ok, | ||
success: Enum.slice(examples, 0, 1), | ||
errors: Enum.slice(examples, 2, 3) | ||
} | ||
end | ||
|
||
test "Success", context do | ||
Enum.each(context[:success], &(assert(&1.status == :success))) | ||
end | ||
|
||
test "Errors", context do | ||
Enum.each(context[:errors], &(assert(&1.status == :failure))) | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
defmodule Boolean.BeTrue do | ||
defmodule Boolean.BeTrueTest do | ||
use ExUnit.Case, async: true | ||
|
||
defmodule SomeSpec do | ||
|
This file contains 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