diff --git a/lib/dynamo/filters/exceptions/debug.ex b/lib/dynamo/filters/exceptions/debug.ex index b7dc50d..5d5c7d8 100644 --- a/lib/dynamo/filters/exceptions/debug.ex +++ b/lib/dynamo/filters/exceptions/debug.ex @@ -149,5 +149,5 @@ defmodule Dynamo.Filters.Exceptions.Debug do require EEx EEx.function_from_file :defp, :template, - Path.expand("../template.eex", __FILE__), [:conn, :assigns] + Path.expand("template.eex", __DIR__), [:conn, :assigns] end diff --git a/lib/mix/tasks/dynamo.ex b/lib/mix/tasks/dynamo.ex index 8cba144..8f87dbd 100644 --- a/lib/mix/tasks/dynamo.ex +++ b/lib/mix/tasks/dynamo.ex @@ -53,7 +53,7 @@ defmodule Mix.Tasks.Dynamo do lib = underscore(mod) dynamo = if opts[:dev] do - %s(path: "#{Path.expand("../../../..", __FILE__)}") + %s(path: "#{Path.expand("../../..", __DIR__)}") else %s(github: "elixir-lang/dynamo") end diff --git a/test/dynamo/connection/test_test.exs b/test/dynamo/connection/test_test.exs index 8a12a7c..a6b372e 100644 --- a/test/dynamo/connection/test_test.exs +++ b/test/dynamo/connection/test_test.exs @@ -186,7 +186,7 @@ defmodule Dynamo.Connection.TestTest do end test :sendfile do - file = Path.expand("../../../fixtures/static/file.txt", __FILE__) + file = Path.expand("../../fixtures/static/file.txt", __DIR__) conn = conn(:GET, "/").sendfile(200, file) assert conn.state == :sent assert conn.status == 200 diff --git a/test/dynamo/cowboy/connection_test.exs b/test/dynamo/cowboy/connection_test.exs index f55496b..6c84708 100644 --- a/test/dynamo/cowboy/connection_test.exs +++ b/test/dynamo/cowboy/connection_test.exs @@ -358,7 +358,7 @@ defmodule Dynamo.Cowboy.ConnectionTest do end def sendfile(conn) do - file = Path.expand("../../../fixtures/static/file.txt", __FILE__) + file = Path.expand("../../fixtures/static/file.txt", __DIR__) conn = conn.sendfile(200, file) assert conn.state == :sent assert conn.status == 200 @@ -390,7 +390,7 @@ defmodule Dynamo.Cowboy.ConnectionTest do end def before_send_with_sendfile(conn) do - file = Path.expand("../../../fixtures/static/file.txt", __FILE__) + file = Path.expand("../../fixtures/static/file.txt", __DIR__) conn.before_send(fn(conn) -> assert conn.state == :sendfile assert conn.status == 201 diff --git a/test/dynamo/cowboy/ssl_test.exs b/test/dynamo/cowboy/ssl_test.exs index 61dced0..c9ab154 100644 --- a/test/dynamo/cowboy/ssl_test.exs +++ b/test/dynamo/cowboy/ssl_test.exs @@ -26,8 +26,8 @@ defmodule Dynamo.Cowboy.SSLTest do config :ssl, port: 8022, password: "cowboy", - keyfile: Path.expand("../../../fixtures/ssl/key.pem", __FILE__), - certfile: Path.expand("../../../fixtures/ssl/cert.pem", __FILE__) + keyfile: Path.expand("../../fixtures/ssl/key.pem", __DIR__), + certfile: Path.expand("../../fixtures/ssl/cert.pem", __DIR__) end setup_all do diff --git a/test/dynamo/filters/exceptions/debug_test.exs b/test/dynamo/filters/exceptions/debug_test.exs index d9d7499..3d07c8f 100644 --- a/test/dynamo/filters/exceptions/debug_test.exs +++ b/test/dynamo/filters/exceptions/debug_test.exs @@ -6,7 +6,7 @@ defmodule Dynamo.Filters.Exceptions.DebugTest do config :dynamo, source_paths: ["filters/exceptions"], exceptions_editor: "editor://__FILE__:__LINE__", - root: Path.expand("../../..", __FILE__) # test/dynamo + root: Path.expand("../..", __DIR__) # test/dynamo end use ExUnit.Case, async: true @@ -35,7 +35,7 @@ defmodule Dynamo.Filters.Exceptions.DebugTest do test "show editor links" do conn = @endpoint.service(conn) - assert conn.sent_body =~ %r"editor://#{URI.encode __FILE__}:#{16}" + assert conn.sent_body =~ %r"editor://#{URI.encode __ENV__.file}:#{16}" end test "shows snippets if they are part of the source_paths" do diff --git a/test/dynamo/filters/exceptions_test.exs b/test/dynamo/filters/exceptions_test.exs index d072211..9d477b6 100644 --- a/test/dynamo/filters/exceptions_test.exs +++ b/test/dynamo/filters/exceptions_test.exs @@ -13,7 +13,7 @@ defmodule Dynamo.Filters.ExceptionsTest do filter Dynamo.Filters.Exceptions.new(Dynamo.Filters.Exceptions.Public) def root do - __FILE__ + __ENV__.file end # Halt diff --git a/test/dynamo/filters/static_test.exs b/test/dynamo/filters/static_test.exs index fdfaa4b..0e6583a 100644 --- a/test/dynamo/filters/static_test.exs +++ b/test/dynamo/filters/static_test.exs @@ -3,7 +3,7 @@ defmodule Dynamo.Filters.StaticTest do use Dynamo use Dynamo.Router - config :dynamo, root: Path.expand("../../..", __FILE__) + config :dynamo, root: Path.expand("../..", __DIR__) filter Dynamo.Filters.Static.new("/public", "") diff --git a/test/dynamo/http/render_test.exs b/test/dynamo/http/render_test.exs index 6397b3c..42f90ab 100644 --- a/test/dynamo/http/render_test.exs +++ b/test/dynamo/http/render_test.exs @@ -24,7 +24,7 @@ defmodule Dynamo.HTTP.RenderTest do config :dynamo, endpoint: RenderingRouter, - templates_paths: [Path.expand("../../../fixtures/templates", __FILE__)] + templates_paths: [Path.expand("../../fixtures/templates", __DIR__)] templates do import List, only: [flatten: 1], warn: false diff --git a/test/dynamo/reloader_test.exs b/test/dynamo/reloader_test.exs index cf66b2b..1f54660 100644 --- a/test/dynamo/reloader_test.exs +++ b/test/dynamo/reloader_test.exs @@ -2,7 +2,7 @@ defmodule Dynamo.LoaderTest do use ExUnit.Case defp fixture_path do - Path.expand("../../fixtures/reloader", __FILE__) + Path.expand("../fixtures/reloader", __DIR__) end setup_all do diff --git a/test/dynamo/templates/finder_test.exs b/test/dynamo/templates/finder_test.exs index bf2264f..984fdd0 100644 --- a/test/dynamo/templates/finder_test.exs +++ b/test/dynamo/templates/finder_test.exs @@ -1,7 +1,7 @@ defmodule Dynamo.Templates.FinderTest do use ExUnit.Case, async: true - @fixture_path Path.expand("../../../fixtures/templates", __FILE__) + @fixture_path Path.expand("../../fixtures/templates", __DIR__) test "finds available template" do path = Path.join(@fixture_path, "hello.html.eex") @@ -20,4 +20,4 @@ defmodule Dynamo.Templates.FinderTest do test "returns nil if no template is found" do assert Dynamo.Templates.Finder.find(@fixture_path, "unknown.html") == nil end -end \ No newline at end of file +end diff --git a/test/dynamo/templates_test.exs b/test/dynamo/templates_test.exs index 7b3b499..34fd983 100644 --- a/test/dynamo/templates_test.exs +++ b/test/dynamo/templates_test.exs @@ -2,7 +2,7 @@ defmodule Dynamo.TemplatesTest do use ExUnit.Case, async: true @renderer __MODULE__.Renderer - @fixture_path Path.expand("../../fixtures/templates", __FILE__) + @fixture_path Path.expand("../fixtures/templates", __DIR__) setup_all do Dynamo.Templates.Renderer.start_link(@renderer) @@ -35,7 +35,7 @@ defmodule Dynamo.TemplatesTest do cached = render "module.html" assert module == cached - template = Path.expand("../../fixtures/templates/module.html.eex", __FILE__) + template = Path.expand("../fixtures/templates/module.html.eex", __DIR__) try do File.touch!(template, { { 2030, 1, 1 }, { 0, 0, 0 } }) @@ -90,4 +90,4 @@ defmodule Dynamo.TemplatesTest do end end end -end \ No newline at end of file +end diff --git a/test/dynamo_test.exs b/test/dynamo_test.exs index 8f1a252..c731bc6 100644 --- a/test/dynamo_test.exs +++ b/test/dynamo_test.exs @@ -5,14 +5,14 @@ defmodule DynamoTest do use Dynamo config :dynamo, - root: Path.expand("../fixtures", __FILE__), + root: Path.expand("fixtures", __DIR__), endpoint: DynamoTest, - static_root: Path.expand("../fixtures/public", __FILE__), + static_root: Path.expand("fixtures/public", __DIR__), static_route: "/public", compile_on_demand: false, reload_modules: false, - source_paths: [Path.expand("../fixtures/*", __FILE__)], - templates_paths: [Path.expand("../fixtures/templates", __FILE__)] + source_paths: [Path.expand("fixtures/*", __DIR__)], + templates_paths: [Path.expand("fixtures/templates", __DIR__)] # Test session compilation as well config :dynamo, @@ -41,13 +41,13 @@ defmodule DynamoTest do end test "defines root based on user config" do - assert App.root == Path.expand("../fixtures", __FILE__) + assert App.root == Path.expand("fixtures", __DIR__) end ## Filters test "adds public filter" do - file = Path.expand("../fixtures/public", __FILE__) + file = Path.expand("fixtures/public", __DIR__) assert Enum.first(App.__filters__) == Dynamo.Filters.Static.new("/public", file) end @@ -67,7 +67,7 @@ defmodule DynamoTest do test "defines templates paths" do assert App.templates_paths == [DynamoTest.App.CompiledTemplates] - templates = Path.expand("../fixtures/templates", __FILE__) + templates = Path.expand("fixtures/templates", __DIR__) assert ReloadApp.templates_paths == [templates] end end diff --git a/test/test_helper.exs b/test/test_helper.exs index 7bc228c..e91ad11 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -14,7 +14,7 @@ defmodule MixHelpers do import ExUnit.Assertions def tmp_path do - Path.expand("../../tmp", __FILE__) + Path.expand("../tmp", __DIR__) end def tmp_path(extension) do