assertions icon indicating copy to clipboard operation
assertions copied to clipboard

Fix compilation errors

Open randycoulman opened this issue 3 years ago • 5 comments

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:

randycoulman avatar Nov 28 '21 06:11 randycoulman

@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 avatar Dec 08 '21 16:12 darrenklein

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

darrenklein avatar Dec 11 '21 18:12 darrenklein

@devonestes just a friendly ping, thank you!

darrenklein avatar Feb 22 '22 16:02 darrenklein

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.

mattste avatar May 13 '22 23:05 mattste

@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

rizasal avatar Nov 07 '22 06:11 rizasal