ExVCR - How to structure tests

I’m currently using the package ExVCR and want to know how to use it properly. After searching the forum and the docs, I can’t seem to find out how to do this or if it’s even an appropriate use case.

What my app is doing

I have a map %{name, url} which I’m iterating over for my basic test of hitting the endpoint:

            for {name, url} <- AnotherModule.get_things() do
                use_cassette "things_#{name}" do
                    assert HTTPoison.get!(url).body =~ ~r/something interesting/

The Challenge

I then process this down stream in a pipeline. Poison |> pattern matching functions. My questions are:

  • Do I need to nest all of testing downstream processing within this one test?
  • The alternative is to use these in subsequent tests… is there a way to do this? I could File.read but wondered if there is a way built in with ExVCR
  • Or do I need to add the boilerplate on each test for {name, thing} and use cassette each time?

Thanking you in advance

1 Like