Sha256: 6682f64c1e4d475c894e13642d522020ede1838cd47a06a24debc5ab60059c35

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

RSpec::Matchers.define :compile do
  include Liquidscript

  chain :and_produce do |prod|
    @prod = prod
  end

  match do |data|
    if @prod
      (@_out = compiler(data).compile) == @prod
    else
      @_out = compiler(data).compile?
    end
  end

  failure_message_for_should do |data|
    "expected #{data} to compile correctly"
  end

  failure_message_for_should_not do |data|
    "expected #{data} not to compile (compiled anyway, got: #{@_out})"
  end

  description do |data|
    "compile #{data}"
  end

  diffable

  def expected
    @prod
  end

  def actual
    (@_out || []).to_a!
  end

  def compiler(data)
    Compiler::ICR.new(Scanner::Liquidscript.new(data))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
liquidscript-0.4.1 spec/support/matchers/compile.rb
liquidscript-0.4.0 spec/support/matchers/compile.rb