Sha256: 624ce01382643bbab0c9aafb242437ce75460a250b206c2d8306bf4f6c4ce779

Contents?: true

Size: 1003 Bytes

Versions: 14

Compression:

Stored size: 1003 Bytes

Contents

require "konacha/reporter/metadata"

# The Example class mimics the public interface of RSpec::Core::Example.

module Konacha
  class Reporter
    class Example
      attr_reader :metadata, :parent

      def initialize(data, parent)
        @metadata = Metadata.new(data)
        @parent = parent
        if parent
          update_metadata(example_group: parent.metadata)
        end
      end

      delegate :full_description, :description, :location, :file_path, :line_number, :pending, :pending_message, :exception, :execution_result, :to => :metadata

      alias_method :pending?, :pending
      alias_method :options, :metadata
      alias_method :example_group, :parent

      def passed?
        execution_result[:status] == "passed"
      end

      def failed?
        execution_result[:status] == "failed"
      end

      def update_metadata(data)
        metadata.update(data)
      end

      def [](key)
        respond_to?(key) ? send(key) : metadata[key]
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
konacha-4.0.0 lib/konacha/reporter/example.rb
konacha-3.7.0 lib/konacha/reporter/example.rb
konacha-3.6.0 lib/konacha/reporter/example.rb
konacha-3.5.1 lib/konacha/reporter/example.rb
konacha-3.5.0 lib/konacha/reporter/example.rb
konacha-3.4.0 lib/konacha/reporter/example.rb
konacha-3.3.0 lib/konacha/reporter/example.rb
konacha-3.2.5 lib/konacha/reporter/example.rb
konacha-3.2.4 lib/konacha/reporter/example.rb
konacha-3.2.3 lib/konacha/reporter/example.rb
konacha-3.2.2 lib/konacha/reporter/example.rb
konacha-3.2.1 lib/konacha/reporter/example.rb
konacha-3.2.0 lib/konacha/reporter/example.rb
konacha-3.1.0 lib/konacha/reporter/example.rb