Sha256: ad05cdb6b1a8bbd334b0dd9ef97db12288187fa6814a650df3b07c506556e1e4

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Sweet
  module Format
    module Cucumber
      class Step
        class << self
          def from_output(data)
            data = JSON.parse(data, symbolize_names: true) if data.is_a? String

            message = [
              data[:result][:error_message],
              data[:result][:pending_message],
              data[:result][:skipped_message]
            ].compact.first

            new keyword: data[:keyword],
                name: data[:name],
                line_number: data[:line],
                status: data[:result][:status],
                duration: data[:result][:duration],
                message: message
          end
        end

        attr_accessor :keyword, :name, :line_number, :status, :duration,
                      :message

        def initialize(opts = {})
          @keyword = opts[:keyword]
          @name = opts[:name]
          @line_number = opts[:line_number]
          @status = opts[:status].to_sym if opts[:status]
          @duration = opts[:duration] || 0.0
          @message = opts[:message]
        end

        def failed?
          @status == :failed
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sweets-0.0.1 lib/sweet/format/cucumber/step.rb