Sha256: 4f69f5f8fc6d7d15be6710fe6a58340321c6e2628698f1917009246271d2c541

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require "cucumber_booster_config/cucumber_file"

module CucumberBoosterConfig

  class Injection

    CUCUMBER_FILES = [
      "cucumber.yml",
      "config/cucumber.yml"
    ]

    def initialize(path, report_path, options = {})
      @path = path
      @report_path = report_path
      @dry_run = options.fetch(:dry_run, false)
    end

    def find_profile_files
      profile_files = []

      CUCUMBER_FILES.map { |file_name| cucumber_file_path(file_name) }.each do |file|
        if File.exist?(file)
          puts "Found Cucumber profile file: #{file}"
          profile_files << file
        end
      end

      profile_files
    end

    def run
      if no_profile_files?
        puts "No cucumber profile files found. Creating empty cucumber.yml file"
        FileUtils.touch("cucumber.yml")
      end

      find_profile_files.each do |path|
        CucumberFile.new(path, @dry_run).configure_for_autoparallelism(@report_path)
      end
    end

    private

    def no_profile_files?
      find_profile_files.empty?
    end

    def cucumber_file_path(file_name)
      File.join(@path, file_name)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
semaphore_cucumber_booster_config-1.4.2 lib/cucumber_booster_config/injection.rb
treye-semaphore_cucumber_booster_config-1.4.2 lib/cucumber_booster_config/injection.rb
semaphore_cucumber_booster_config-1.4.1 lib/cucumber_booster_config/injection.rb
semaphore_cucumber_booster_config-1.4.0 lib/cucumber_booster_config/injection.rb