Closed cjlarose closed 3 years ago
Tests fail when using the Sinatra Gemfiles, which is more-or-less expected: if you don't have the ActiveSupport Core Extensions loaded, then Hash#as_json
isn't defined.
I don't know yet what the right fix is. I'm considering skipping the test except when testing against Rails, since the method sort of has an implicit dependency on ActiveSupport. If a user isn't in the Rails ecosystem or otherwise using ActiveSupport
, then I wouldn't expect them to call #as_json
anyway.
It's possible to, at runtime, check to_hash.repsond_to?(:as_json)
and do something differently if it doesn't respond to that method, but it's not 100% clear what we'd return in that case.
@pkuczynski Updated to skip the test except when running against Rails. LMK what you think!
Looks very good to me! I will merge it in and release new version :) Thanks for all your hard work on this @cjlarose!
Fixes #287
Before,
Config::Options#as_json
was not explicitly defined, but the class included theEnumerable
module. So, if you were using ActiveSupport Core Extensions, then the definition of#as_json
for Enumerable was invoked, which would represent theConfig::Options
as a Array of key-value pairs instead of a Hash.This changes brings
#as_json
in line with the output we get fromto_json
: essentially, calling these methods on an instance ofConfig::Options
behaves the same as if they were called instead on the hash returned byto_hash
.It's not clear if this is a "bug fix" or a "breaking change" from a semver perspective, but I think it's unlikely that someone was depending on the output from
#as_json
to be the Array-of-pairs representation.