Sha256: 4a071a6434d3e4c24fcb7fcf68dbd2f8c8ffcbf2f63d2f992b7d65fd43efdfeb

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'

class DiscoApp::CanBeLiquifiedTest < ActiveSupport::TestCase

  class Model

    include ActiveModel::Model
    include DiscoApp::Concerns::CanBeLiquified

    def initialize(attributes = {})
      @attributes = attributes
    end

    def as_json
      @attributes.as_json
    end

    def liquid_model_name
      'model'
    end

  end

  def setup
    @model = Model.new(
      numeric: 42,
      boolean: true,
      empty: nil,
      string: "The cat's pyjamas are \"great\".",
      string_html: "The cat's pyjamas are <strong style=\"color: red;\">great</strong>.",
      array_of_numerics: [1, 2, 3],
      array_of_strings: ['A', 'B', 'C'],
      hash: {}
    )
  end

  def teardown
    @model = nil
  end

  ##
  # Test Liquid output.
  ##

  test 'correct liquid is output for model' do
    assert_equal liquid_fixture('model.liquid'), @model.to_liquid
  end

  private

    # Return an asset fixture as a string.
    def liquid_fixture(path)
      filename = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'fixtures', 'liquid', path.to_s)
      File.read(filename).strip
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.18.0 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.18.2 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.18.3 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.18.6 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.18.4 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.18.1 test/models/disco_app/can_be_liquified_test.rb