grape-roar
is an amazing Ruby gem that makes it easy to parse and render REST API documents using Presenters in Grape
. While upgrading from a pretty old version, it broke one of the tests. Took me quite a bit to figure out what actually was going wrong so putting this out for easier recall.
The breakdown was something like this. We had a presenter class:
|
|
We were calling it in this manner:
|
|
After the upgrade to the latest grape-roar
, representable
and roar
versions, this broke the POST API with the following error:
NoMethodError: undefined method `title` for <ActiveSupport::HashWithIndifferentAccess:0x...>
which looks like a very weird error. After racking my brains for quite some time, it occurred to me that in the documentation for all these gems they’ve always specified a class as the input to the SongPresenter.new
constructor.
I changed the line
|
|
|
|
At the same time, it looks like there hasn’t been any activity on the grape-roar
repo in a while, so might be a good idea to migrate away from that dependency to avoid the same pains in the future.