Packages
espec
0.7.1
1.10.0
1.9.2
1.9.1
1.9.0
1.8.3
1.8.2
1.8.1
1.8.0
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.1
1.5.0
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
0.8.28
0.8.27
0.8.26
0.8.25
0.8.24
0.8.23
0.8.22
0.8.21
0.8.20
0.8.19
0.8.18
0.8.17
0.8.16
0.8.15
0.8.14
0.8.13
0.8.12
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.1
0.8.0
0.7.2
0.7.1
0.7.0
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.7
0.3.5
0.3.0
0.2.0
0.1.0
BDD testing framework for Elixir inspired by RSpec.
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/init.ex
defmodule Mix.Tasks.Espec.Init do
use Mix.Task
import Mix.Generator
@shortdoc "Create spec/spec_helper.exs and spec/example_spec.exs"
@spec_folder "spec"
@spec_helper "spec_helper.exs"
@example_spec "example_spec.exs"
def run(_args) do
create_directory @spec_folder
create_file(Path.join(@spec_folder, @spec_helper), spec_helper_template(nil))
create_file(Path.join(@spec_folder, @example_spec), example_spec_template(nil))
end
embed_template :spec_helper, """
ESpec.start
ESpec.configure fn(config) ->
config.before fn ->
# {:ok, hello: :world}
end
config.finally fn(__) ->
end
end
"""
embed_template :example_spec, """
defmodule ExampleSpec do
use ESpec
before do
answer = Enum.reduce((1..9), &(&2 + &1)) - 3
{:ok, answer: answer} #saves {:key, :value} to `__`
end
example "test" do
expect(__.answer).to eq(42)
end
context "Defines context" do
subject(__.answer)
it do: is_expected.to be_between(41, 43)
describe "is an alias for context" do
before do
value = __.answer * 2
{:ok, new_answer: value}
end
let :val, do: __.new_answer
it "checks val" do
expect(val).to eq(84)
end
end
end
xcontext "xcontext skips examples." do
xit "And xit also skips" do
"skipped"
end
end
pending "There are so many features to test!"
end
"""
end