Sha256: 433956f59f9e55cb95ee93c67f1f1ce6acfcac3de9db95ed2725d927bd8d93c1

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

def render_template(source, context = nil, options = {})
  context ||= ::Liquid::Context.new
  context.exception_handler = ->(e) { true }
  ::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
    end

    def before_method(meth)
      @_source[meth.to_sym]
    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

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.beta.3 spec/support/liquid.rb