Skip to content

Commit

Permalink
Merge pull request dynamo#178 from guilleiguaran/fix-warnings
Browse files Browse the repository at this point in the history
__FILE__ is deprecated, we should use __DIR__ or __ENV__.file instead
  • Loading branch information
Devin Torres committed Jan 6, 2014
2 parents 976a66f + 7b8a284 commit 972b4b6
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/dynamo/filters/exceptions/debug.ex
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/mix/tasks/dynamo.ex
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dynamo/connection/test_test.exs
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/dynamo/cowboy/connection_test.exs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/dynamo/cowboy/ssl_test.exs
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/dynamo/filters/exceptions/debug_test.exs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dynamo/filters/exceptions_test.exs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dynamo/filters/static_test.exs
Expand Up @@ -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", "")

Expand Down
2 changes: 1 addition & 1 deletion test/dynamo/http/render_test.exs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dynamo/reloader_test.exs
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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")
Expand All @@ -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
end
6 changes: 3 additions & 3 deletions test/dynamo/templates_test.exs
Expand Up @@ -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)
Expand Down Expand Up @@ -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 } })
Expand Down Expand Up @@ -90,4 +90,4 @@ defmodule Dynamo.TemplatesTest do
end
end
end
end
end
14 changes: 7 additions & 7 deletions test/dynamo_test.exs
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion test/test_helper.exs
Expand Up @@ -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
Expand Down

0 comments on commit 972b4b6

Please sign in to comment.