Sha256: ab56e76d1afb27a86f55c6dc5bebe8b602dd19e00cb7a9b66adf51c4c307fc14

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'base64'
require 'turnip_formatter/template'
require 'turnip_formatter/step/failure'

module Gnawrnip
  module StepScreenshot
    class << self
      #
      # @param  [Array]  png_base64_list  array of base64 encoded image
      #
      def build(png_base64_list)
        case png_base64_list.length
        when 0
          ''
        when 1
          single_image(png_base64_list.first)
        else
          animation_image(png_base64_list)
        end
      end

      def animation_image(paths)
        text = '<div class="screenshot animation">'
        text += Gnawrnip.photographer.animation(paths)
        text + '</div>'
      end

      def single_image(path)
        text = '<div class="screenshot">'
        text += Gnawrnip.photographer.single(path)
        text + '</div>'
      end
    end
  end
end

module TurnipFormatter
  Template.add_scss(<<-EOS)
    div#steps-statistics section.scenario {
        ul.steps {
            div.screenshot {
               > img {
                 max-width: 90%;
                 border: 2px solid black;
               }
           }
       }
    }
  EOS

  Step::Failure.add_template Gnawrnip::StepScreenshot do
    example.metadata[:gnawrnip][:screenshot] || []
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gnawrnip-0.1.2 lib/gnawrnip/step_screenshot.rb
gnawrnip-0.1.1 lib/gnawrnip/step_screenshot.rb