Sha256: d2554144e14bd1fed48336063c333d3485121276cc7540b8dc652a6e7aaeefe6

Contents?: true

Size: 671 Bytes

Versions: 9

Compression:

Stored size: 671 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 || []
  end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
liquidscript-0.2.1 spec/support/matchers/compile.rb
liquidscript-0.2.0 spec/support/matchers/compile.rb
liquidscript-0.1.5 spec/support/matchers/compile.rb
liquidscript-0.1.4 spec/support/matchers/compile.rb
liquidscript-0.1.3 spec/support/matchers/compile.rb
liquidscript-0.1.2 spec/support/matchers/compile.rb
liquidscript-0.1.1 spec/support/matchers/compile.rb
liquidscript-0.1.0 spec/support/matchers/compile.rb
liquidscript-0.0.1 spec/support/matchers/compile.rb