Sha256: c087192e9dd879a180a69c440277642848c6eaef4bc33fa56a059f3c738ee55a

Contents?: true

Size: 1016 Bytes

Versions: 14

Compression:

Stored size: 1016 Bytes

Contents

require "konacha/reporter/metadata"

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

module Konacha
  class Reporter
    class ExampleGroup
      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, :file_path, :described_class, :to => :metadata

      alias_method :display_name, :description
      alias_method :example_group, :parent

      def parent_groups
        ancestor = parent
        groups = []
        while ancestor
          groups << ancestor
          ancestor = ancestor.parent
        end

        groups
      end

      alias_method :ancestors, :parent_groups

      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_group.rb
konacha-3.7.0 lib/konacha/reporter/example_group.rb
konacha-3.6.0 lib/konacha/reporter/example_group.rb
konacha-3.5.1 lib/konacha/reporter/example_group.rb
konacha-3.5.0 lib/konacha/reporter/example_group.rb
konacha-3.4.0 lib/konacha/reporter/example_group.rb
konacha-3.3.0 lib/konacha/reporter/example_group.rb
konacha-3.2.5 lib/konacha/reporter/example_group.rb
konacha-3.2.4 lib/konacha/reporter/example_group.rb
konacha-3.2.3 lib/konacha/reporter/example_group.rb
konacha-3.2.2 lib/konacha/reporter/example_group.rb
konacha-3.2.1 lib/konacha/reporter/example_group.rb
konacha-3.2.0 lib/konacha/reporter/example_group.rb
konacha-3.1.0 lib/konacha/reporter/example_group.rb