Skip to content

Manage the Elixir application environment within a context

License

Notifications You must be signed in to change notification settings

fremantle-industries/with_env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WithEnv

Build Status hex.pm version

Manage the Elixir application environment within a context

Installation

Add the with_env package to your list of dependencies in mix.exs:

def deps do
  [{:with_env, "~> 0.1", only: :test}]
end

Usage

defmodule HelloTest do
  use ExUnit.Case
  use WithEnv

  test "can put values into the env" do
    assert Application.get_env(:hello, :saying) == nil

    with_env put: [hello: [saying: "galaxy"]] do
      assert Application.get_env(:hello, :saying) == "galaxy"
    end

    assert Application.get_env(:hello, :saying) == nil
  end

  test "can delete values from the env" do
    Application.put_env(:hello, :saying, "world")

    with_env delete: [hello: [:saying]] do
      assert Application.get_env(:hello, :saying) == nil
    end

    assert Application.get_env(:hello, :saying) == "world"
    assert Application.delete_env(:hello, :saying) == :ok
  end
end

About

Manage the Elixir application environment within a context

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages