Sha256: 299050249b94bc24dcf508eb9f5e67ca571d2fd2d49f83bc9fb5d4beebbda8e3

Contents?: true

Size: 883 Bytes

Versions: 1

Compression:

Stored size: 883 Bytes

Contents

module Petitest
  class AssertionFailureMessage
    # @return [String]
    attr_reader :template

    # @return [Hash{Symbol => Object}]
    attr_reader :template_variables

    # @return [String, nil]
    attr_reader :user_specified_message

    # @param template [String]
    # @param template_variables [Hash{Symbol => Object}]
    # @param user_specified_message [String, nil]
    def initialize(template:, template_variables: {}, user_specified_message:)
      @template = template
      @template_variables = template_variables
      @user_specified_message = user_specified_message
    end

    # @note Override
    def to_s
      template % inspected_template_variables
    end

    private

    # @return [Hash{Symbol => String}]
    def inspected_template_variables
      template_variables.map do |key, value|
        [key, value.inspect]
      end.to_h
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
petitest-0.1.0 lib/petitest/assertion_failure_message.rb