Sha256: efd04be5d17c073285bdf67db360da4f34d0265312a4d28611ac9a920c76684f

Contents?: true

Size: 1007 Bytes

Versions: 2

Compression:

Stored size: 1007 Bytes

Contents

# -*- coding: utf-8 -*-

module TurnipFormatter
  class Step
    attr_reader :name, :docs, :example

    class << self
      def templates
        @templates ||= {}
      end

      def add_template(status, klass = nil, &block)
        templates[status] ||= {}
        templates[status][klass] = { klass: klass, block: block }
      end

      def remove_template(status, klass)
        key = status.to_sym
        return unless templates.key?(key)
        templates[key].delete(klass)
        templates.delete(key) if templates[key].empty?
      end

      def status
        ''
      end
    end

    #
    # @param  [RSpec::Core::Example]  example
    # @param  [Hash]  description
    #
    def initialize(example, description)
      @example = example
      @name = description[:keyword] + description[:name]
      @docs = { extra_args: { klass: nil, value: description[:extra_args] } }
    end

    def attention?
      !status.empty?
    end

    def status
      self.class.status
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
turnip_formatter-0.2.11 lib/turnip_formatter/step.rb
turnip_formatter-0.2.10 lib/turnip_formatter/step.rb