Skip to content

MainShayne233/markdown_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MarkdownTest

Build Status Coverage Status

Test the Elixir code in your markdown!

Usage

Add :markdown_test as a dependency in your mix.exs file:

# mix.exs

defp deps do
  [
    {:markdown_test, "0.1.0", only: :test}
  ]
end

In any test module, use MarkdownTest to pull in the test_markdown/1 macro and call it for your markdown file:

defmodule MyLibraryTest do
  use MarkdownTest

  test_markdown("README.md")
end

Then add some Elixir code to test in your markdown file.

The format roughly resembles that of a doctest.

In order to be picked up, a code block must be between the following markdown comment tags:

<!--- MARKDOWN_TEST_START -->

...code

<!--- MARKDOWN_TEST_END -->.

Examples

iex> 1 + 2
3

The expression and expected values can span multiple lines:

iex> a = %{cool: :beans}
...> b = %{beans: :cool}
...> Map.merge(a, b)
%{
  cool: :beans,
  beans: :cool
}

You can also include any setup code that needs to be run prior to testing the code:

defmodule MyModule do
  def add(x, y), do: x + y
end

iex> MyModule.add(1, 2)
3

About

Test the Elixir code in your markdown files!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages