Sha256: 22da8d45e27d13542f687a837ef43229378c896ae71f049f27698e9bc9e5c2b5

Contents?: true

Size: 1.14 KB

Versions: 29

Compression:

Stored size: 1.14 KB

Contents

def render_template(source, context = nil, options = {})
  context ||= ::Liquid::Context.new
  context.exception_handler = ->(e) { true }
  Locomotive::Steam::Liquid::Template.parse(source, options).render(context)
end

def parse_template(source, options = nil)
  ::Liquid::Template.parse(source, options || {})
end

module Liquid

  class TestDrop < Liquid::Drop
    def initialize(source)
      @_source = source.with_indifferent_access
    end

    def before_method(meth)
      @_source[meth.to_sym]
    end

    def as_json(options = nil)
      @_source.as_json(options)
    end
  end

  class SimpleEventsListener
    def initialize
      ActiveSupport::Notifications.subscribe(/^steam\.parse\./) do |name, start, finish, id, payload|
        emit(name, payload)
      end
    end
    def emit(name, options = {})
      (@stack ||= []) << [name, options]
    end
    def event_names
      (@stack || []).map { |(name, _)| name }
    end
    def events
      @stack || []
    end
  end
end

def liquid_instance_double(doubled_class, stubs)
  instance_double(doubled_class, stubs).tap do |double|
    allow(double).to receive(:to_liquid).and_return(double)
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.0 spec/support/liquid.rb
locomotivecms_steam-1.1.0.rc3 spec/support/liquid.rb
locomotivecms_steam-1.1.0.rc2 spec/support/liquid.rb
locomotivecms_steam-1.1.0.rc1 spec/support/liquid.rb
locomotivecms_steam-1.0.1 spec/support/liquid.rb
locomotivecms_steam-1.0.0 spec/support/liquid.rb
locomotivecms_steam-1.0.0.rc10 spec/support/liquid.rb
locomotivecms_steam-1.0.0.rc9 spec/support/liquid.rb
locomotivecms_steam-1.0.0.rc8 spec/support/liquid.rb