Adding DSL test helpers
One key element to making your DSL easy to use is to add easier ways to test the DSL. Oftentimes, this means adding ways to test whether the DSL is being used correctly and will yield the expected output. Most of this can be done by adding some introspective features, such as the __sequences__/0
function.
In order to make our DSL more testable, we can define a cleaner way to test whether a sequence was defined with expected notes. Let’s define the MixMusic.DSLTestHelper
module:
lib/mix_music/dsl/test_helpers.ex
defmodule MixMusic.DSL.TestHelper do @moduledoc """ Test helpers for MixMusic.DSL """ def defines_sequence?(module, sequence_name, with_notes: notes) do actual_notes = ...