Sha256: 8395ed78d6b3990167c6316b507104f3641f8ca4021cb050b3a97085aa34cfea

Contents?: true

Size: 1 KB

Versions: 12

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module FastCI
  class  ExtractDescriptions
    def call(example_group, count: false)
      data = {}

      data[scoped_id(example_group)] = {
        description: description(example_group),
        line_number: line_number(example_group),
      }

      if count
        data[:test_count] ||= 0
        data[:test_count] += RSpec.world.example_count([example_group])
      end

      example_group.examples.each do |ex|
        data[scoped_id(example_group)][scoped_id(ex)] = {
          line_number: line_number(ex),
          description: description(ex),
        }
      end

      example_group.children.each do |child|
        data[scoped_id(example_group)].merge! call(child)
      end

      data
    end

    def scoped_id(example_group)
      example_group.metadata[:scoped_id].split(":").last
    end

    def line_number(example_group)
      example_group.metadata[:line_number]
    end

    def description(example_group)
      example_group.metadata[:description]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fast_ci-1.0.11 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.10 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.9 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.8 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.7 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.6 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.5 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.4 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.3 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.2 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.1 lib/fast_ci/extract_definitions.rb
fast_ci-1.0.0 lib/fast_ci/extract_definitions.rb