Sha256: 18dda4be0003a7610a126632c5cb46bab8686687d3f59f3f9a97e53048e3ba8d

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require 'turnip_formatter'
require 'turnip_formatter/renderer/html/base'
require 'turnip_formatter/renderer/html/doc_string'
require 'turnip_formatter/renderer/html/data_table'
require 'turnip/table'

module TurnipFormatter
  module Renderer
    module Html
      #
      # @resource [TurnipFormatter::Resource::Step]
      #
      class Step < Base
        delegate :text, :status

        def keyword
          @resource.keyword.strip
        end

        def argument
          @argument ||= case @resource.argument
                        when ::Turnip::Table
                          DataTable.new(@resource.argument).render
                        when String
                          DocString.new(@resource.argument).render
                        end
        end

        def extra_information
          extra_information_templates.map do |template, method|
            template.send(method, @resource.example)
          end.join("\n")
        end

        def has_appendix?
          !!argument or !extra_information_templates.empty?
        end

        private

        def extra_information_templates
          @extra_information_templates ||= TurnipFormatter.step_templates_for(status)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
turnip_formatter-0.6.0.pre.beta.6 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.0.pre.beta.5 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.0.pre.beta.4 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.0.pre.beta.3 lib/turnip_formatter/renderer/html/step.rb
turnip_formatter-0.6.0.pre.beta.2 lib/turnip_formatter/renderer/html/step.rb