Sha256: 0c6c8c89213ea1d8e1372035f4ebf6ed66219a84311d4fff1f39c466b007faed

Contents?: true

Size: 1.11 KB

Versions: 35

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}")
      File.read(filename).strip
    end

end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release test/models/disco_app/can_be_liquified_test.rb
disco_app-0.9.11 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.10.0 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.10.1 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.10.2 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.10.3 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.10.4 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.10.5 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.11.0 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.11.1 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.12.0 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.12.1 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.12.5 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.12.6 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.12.7 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.13.0 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.13.1 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.13.2 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.13.3 test/models/disco_app/can_be_liquified_test.rb
disco_app-0.13.4 test/models/disco_app/can_be_liquified_test.rb