Skip to content

Commit

Permalink
antonmi#93 Ability to run ESpec mix task twice in a stack of tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmi committed Mar 28, 2016
1 parent 744b0d2 commit db06c28
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
13 changes: 9 additions & 4 deletions lib/mix/tasks/espec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ defmodule Mix.Tasks.Espec do
Mix.Task.run "app.start", args

ensure_espec_loaded!
set_configuration(opts)

parse_spec_files(project, opts, files)
ESpec.start
parse_spec_files(project, files)

success = ESpec.run

Expand Down Expand Up @@ -170,12 +172,15 @@ defmodule Mix.Tasks.Espec do
end
end

defp parse_spec_files(project, opts, files) do
defp set_configuration(opts) do
ESpec.Configuration.add(start_loading_time: :os.timestamp)
ESpec.Configuration.add(opts)
end

defp parse_spec_files(project, files) do
spec_paths = project[:spec_paths] || ["spec"]
spec_pattern = project[:spec_pattern] || "*_spec.exs"

ESpec.Configuration.add(start_loading_time: :os.timestamp)
ESpec.Configuration.add(opts)
Enum.each(spec_paths, &require_spec_helper(&1))

files_with_opts = []
Expand Down
2 changes: 0 additions & 2 deletions lib/mix/tasks/init.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ defmodule Mix.Tasks.Espec.Init do
end

embed_template :spec_helper, """
ESpec.start
ESpec.configure fn(config) ->
config.before fn ->
{:shared, hello: :world}
Expand Down
2 changes: 0 additions & 2 deletions spec/spec_helper.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ESpec.start

ESpec.configure fn(config) ->
config.before fn -> {:ok, answer: 42} end
config.finally fn(shared) -> shared.answer end
Expand Down
1 change: 0 additions & 1 deletion test/mix/espec_init_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ defmodule EspecInitTest do

test "spec_helper content" do
{:ok, content} = File.read(Path.join(@tmp_path, "spec/spec_helper.exs"))
assert content =~ "ESpec.start"
assert content =~ "ESpec.config"
end

Expand Down

0 comments on commit db06c28

Please sign in to comment.