diff --git a/lib/trmnl/liquid.rb b/lib/trmnl/liquid.rb index e6b8538..ccf047d 100644 --- a/lib/trmnl/liquid.rb +++ b/lib/trmnl/liquid.rb @@ -5,6 +5,16 @@ require "trmnl/liquid/filters" require "trmnl/liquid/memory_system" require "trmnl/liquid/template_tag" +# rubocop:todo Style/OneClassPerFile +module Liquid + # TODO: Remove once Liquid is patched. Broken since Liquid 5.13.0. Issue: 2107. + module Utils + def self.inspect(object = nil, seen = {}) = seen.empty? ? object.to_s : super + + def self.to_s(object = nil, seen = {}) = seen.empty? ? object.to_s : super + end +end + module TRMNL # Main namespace. module Liquid @@ -32,3 +42,4 @@ module TRMNL end end end +# rubocop:enable Style/OneClassPerFile diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1577f56..e87bf94 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,13 +8,6 @@ unless ENV["COVERAGE"] == "no" end end -# TODO: Remove once the Liquid gem is fixed because it violates Object#inspect behavior. -SimpleCov.at_exit do - SimpleCov.result.format! -rescue ArgumentError => error - warn "Liquid object inspection failure: #{error.message}" -end - Bundler.require :tools require "refinements" diff --git a/spec/trmnl/liquid/filters_spec.rb b/spec/trmnl/liquid/filters_spec.rb index 95b63ee..40aaf32 100644 --- a/spec/trmnl/liquid/filters_spec.rb +++ b/spec/trmnl/liquid/filters_spec.rb @@ -57,8 +57,8 @@ RSpec.describe TRMNL::Liquid::Filters do } expect(content).to eq( - %({35=>[{"name"=>"Ryan", "age"=>35}], 29=>[{"name"=>"Sara", "age"=>29}, ) + - %({"name"=>"Jimbob", "age"=>29}]}) + %({35 => [{"name" => "Ryan", "age" => 35}], 29 => [{"name" => "Sara", "age" => 29}, ) + + %({"name" => "Jimbob", "age" => 29}]}) ) end end @@ -84,7 +84,7 @@ RSpec.describe TRMNL::Liquid::Filters do it "finds by name" do content = renderer.call "{{ collection | find_by: 'name', 'Ryan' }}", {"collection" => collection} - expect(content).to eq('{"name"=>"Ryan", "age"=>35}') + expect(content).to eq('{"name" => "Ryan", "age" => 35}') end it "answers fallback when not found" do @@ -293,7 +293,7 @@ RSpec.describe TRMNL::Liquid::Filters do data = {"towns" => [{"id" => 1, "label" => "Boulder"}, {"id" => 2, "label" => "Bozeman"}]} content = renderer.call template, data - expect(content.strip).to eq(%({"id"=>1, "label"=>"Boulder"})) + expect(content.strip).to eq(%({"id" => 1, "label" => "Boulder"})) end it "answers content which matches equation" do