Class: CukeIterations::ScenarioFileWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/cuke_iterations/scenario_file_writer.rb

Instance Method Summary collapse

Instance Method Details

#write_scenarios(features_dir, iteration_file, out_file) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cuke_iterations/scenario_file_writer.rb', line 3

def write_scenarios(features_dir, iteration_file, out_file)
  iterations = YAML.load(File.read(iteration_file))

  all_scenarios = []
  features = CukeParser.parse_features(features_dir)
  iterations.each do |iteration_name, iteration|
    iteration_dir = File.join(features_dir, 'iterations', iteration_name, '..', '..')
    FileUtils.mkdir_p iteration_dir

    ScenarioListGenerator.for_iteration(features, iteration).each do |scenario|
      all_scenarios << File.join(iteration_dir, scenario[:filename] + ":#{scenario[:line]}")
    end
  end

  File.open(out_file, 'w') { |f| f.puts all_scenarios }
end