Sha256: bc97fdf6588ff8c58c53359ccee4d5d84aac979909e66709f922c2ee00941ebb

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'minitest/spec'
require 'minitest/autorun'
require_relative '../lib/liquid-validator'

describe LiquidValidator::Validator do
  describe "#valid?" do
    it "returns true for valid templates" do
      template = <<-TEMPLATE
        {% if something %}
          HAPPY DAY
        {% endif %}
      TEMPLATE
      LiquidValidator::Validator.new(template).valid?.must_equal true
    end

    it "returns false for invalid templates" do
      template = <<-TEMPLATE
        {% if something
          HAPPY DAY
        {% endif %}
      TEMPLATE
      LiquidValidator::Validator.new(template).valid?.must_equal false
    end
  end

  describe "#errors" do
    it "returns an empty array if the template has no errors" do
      template = <<-TEMPLATE
        {% if something %}
          HAPPY DAY
        {% endif %}
      TEMPLATE
      LiquidValidator::Validator.new(template).errors.must_equal []
    end

    it "returns an an array of the errors in the template" do
      template = <<-TEMPLATE
        {% if something
          HAPPY DAY
        {% endif %}
      TEMPLATE
      LiquidValidator::Validator.new(template).errors.must_equal ["Tag '{%' was not properly terminated with regexp: /\\%\\}/ "]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
liquid-validator-1.0.0 test/liquid_validator_test.rb