devonestes / assertions

Helpful assertions for ExUnit
MIT License
143 stars 29 forks source link

Fix compilation errors #27

Open randycoulman opened 3 years ago

randycoulman commented 3 years ago

Fixes #22 Replaces #24

From my reading of the docs and other research, it looks like Code.ensure_loaded? is a better way to check whether an optional dependency module exists or not. Details below. This PR preserves the intention of only including Absinthe-related code when Absinthe is present in the parent project. #24 was a temporary fix to disable the check as I understand it.

This also fixes a formatting-related test failure in the doc tests for assertions/absinthe.ex. I still get 3 test failures in the doc tests (with Elixir 1.12.3), but I'm not sure what the problem is or how to fix them. The errors all happen in format_fields with the message:

** (Protocol.UndefinedError) protocol Enumerable not implemented for :scalar of type Atom. This protocol is implemented for the following type(s): HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream

Details:

darrenklein commented 2 years ago

@devonestes this seems to do the trick, would you consider accepting this PR?

The problem of the three failing doctests is unrelated to this particular issue - I think I see the problem there, will try to experiment with that in the next day or two.

darrenklein commented 2 years ago

@randycoulman I patched up that failing doctest issue in another PR, thanks for bringing it up!

darrenklein commented 2 years ago

@devonestes just a friendly ping, thank you!

mattste commented 2 years ago

I wasn't able to get this P/R to work when doing a fresh install. The error originally popped-up in CI when a fresh install was done. I can't track down a specific reason why but Assertions is being compiled before Absinthe is available. The Code.ensure_loaded? check always returns false.

My workaround for now is a fork that removes the check.

rizasal commented 2 years ago

@mattste Marking the absinthe dependency as optional: true in the mix.exs file helped fix the issue you've mentioned. Currently using a fork that combines #27, #29 and the above change. https://github.com/rizasal/assertions