Adh

Elixir CI

A tiny library of helpers to make assertions on DOM.

Powered by Floki.

Installation

Add Adh to your mix.exs:

defp deps do
  [
    {:adh, "~> 0.1.0"}
  ]
end

Usage

Adh.dom_assert(html_string, assertions)

Where assertions is a Keyword list.

The currently available assertions are:

Ahd.dom_assert return a list of :ok if the assertion was succesfull, or {:fail, reason} otherwhise.

Example:

iex(1)> html = "<p>o/ <span class=&#39;red&#39;>dog</span></p>"
iex(2)> assertions = [dom_count: {"p", 1}, dom_text: {".red", "dig"}]
iex(2)> Adh.dom_assert(html, assertions)
[:ok, {:fail, "dom text: got `dog` instead of `dig`."}]