Sha256: 4867b6c3acb7f8d6cdcf4ae5c98aa6b5e13d53a508a799efc73ad8ff7d123a7c

Contents?: true

Size: 848 Bytes

Versions: 16

Compression:

Stored size: 848 Bytes

Contents

require File.expand_path('../step_definition_file', __FILE__)

class StepManager
  STEP_KINDS = %w[Given When Then]

  attr_accessor :directories, :step_files

  def initialize(*directories)
    self.directories = directories
    self.step_files = directories.map(&method(:collect_files)).flatten.compact
  end

  def to_markdown
    step_files.collect(&:to_markdown).join "\n\n"
  end

  def steps(search = nil)
    step_files.collect(&:real_steps).flatten.
      sort_by { |step| [STEP_KINDS.index(step.kind), step.to_s.downcase] }.
      select { |definition| search.nil? || definition.matches_search?(search) }
  end

private

  def collect_files(directory)
    Dir["#{directory}/**/*_steps.rb"].to_a.sort.map do |filename|
      next if filename.include? 'spreewald/all_steps'
      StepDefinitionFile.new(filename)
    end.compact
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spreewald-4.6.3 support/step_manager.rb
spreewald-4.6.2 support/step_manager.rb
spreewald-4.6.1 support/step_manager.rb
spreewald-4.6.0 support/step_manager.rb
spreewald-4.5.1 support/step_manager.rb
spreewald-4.5.0 support/step_manager.rb
spreewald-4.4.4 support/step_manager.rb
spreewald-4.4.3 support/step_manager.rb
spreewald-4.4.2 support/step_manager.rb
spreewald-4.4.1 support/step_manager.rb
spreewald-4.4.0 support/step_manager.rb
spreewald-4.3.6 support/step_manager.rb
spreewald-4.3.5 support/step_manager.rb
spreewald-4.3.4 support/step_manager.rb
spreewald-4.3.3 support/step_manager.rb
spreewald-4.3.2 support/step_manager.rb