antonmi / espec_phoenix

ESpec for Phoenix web framework.
MIT License
137 stars 33 forks source link

Issue with reading/checking json generated by a controller #25

Closed mlankenau closed 8 years ago

mlankenau commented 8 years ago

Probably not an issue, more a feature request, but...

I try to test a action that is returning json and I see no way doing that. My quick fix is

  result = action(:solve, {"some_params" => "foo"}).resp_body
           |> Poison.decode
           |> case do
            {:ok, data} -> data
           end
  expect(result.solution) |> to(eq  [true, true, false])

There is prabably a better way to do that, but how?

joshrieken commented 8 years ago

@mlankenau I just created a new package, test_that_json_espec, that should hopefully make this easier.

antonmi commented 8 years ago

Thanks, @facto!