| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Simplify your Ecto model validation tests. Loosely inspired by shoulda matchers, but simpler.
Jose Valim, creator of Elixir, has outlined a better approach to this problem here: https://groups.google.com/forum/#!topic/elixir-lang-talk/kwLLyCiarls
Go check it out.
defmodule MyApp.UserTest do
use ExUnit.Case
use Ecto.ValidationCase, model: MyApp.User
test "requires password to be 10 chars long" do
rejects "password", for: :password, message: "too short"
accepts "password123", for: :password
end
endRather than create a matching test helper function for each of the valiations that Ecto supports, this library intentionally keeps things simple, providing only accepts/2 and rejects/2. Why?
You can install Ecto.ValidationCase from hex. First, change your deps in mix.exs specifying that this is applicable only for the test environment:
def deps do
[{:ecto_validation_case, ">= 0.1.0", env: :test}]
endThen run mix deps.get to install.
Documentation is available on Ecto.ValidationCase's hex page.
| Back | FazBrowse Home | New Git URL |