Sha256: 442fc0c78576b30548df02e3fab8338c20e1afa855ffa401e29bed6eeee73b78

Contents?: true

Size: 1 KB

Versions: 27

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module RubyCI
  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

27 entries across 27 versions & 1 rubygems

Version Path
ruby_ci-0.2.26 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.25 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.24 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.23 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.22 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.21 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.20 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.19 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.18 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.17 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.16 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.15 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.14 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.13 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.12 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.11 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.10 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.9 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.8 lib/ruby_ci/extract_definitions.rb
ruby_ci-0.2.7 lib/ruby_ci/extract_definitions.rb