Class: ManaMana::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/manamana/compiler.rb

Instance Method Summary collapse

Instance Method Details

#start(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/manamana/compiler.rb', line 4

def start(options = {})
  options[:requirements_path] = File.join(Dir.pwd, ManaMana::REQUIREMENTS_PATH)
  options[:test_cases_path]   = File.join(Dir.pwd, ManaMana::TEST_CASES_PATH)
  options[:stepdefs_path]     = File.join(Dir.pwd, ManaMana::STEPDEFS_PATH)
  options[:helpers_path]      = File.join(Dir.pwd, ManaMana::HELPERS_PATH)
  options[:output_path]       = File.join(Dir.pwd, '__spec__.rb')
  @options = options

  req_groups = load_and_parse_requirements.groups
  test_cases = load_and_parse_test_cases

  output = ""

  req_groups.each do |group|
    output << "describe \"#{ group.name }\" do\n\n"

    group.all_requirements.each do |r|
      output << test_cases.find(r).translate(r) + "\n"
    end

    output << "end\n\n"
  end

  file = File.new(options[:output_path], 'w')
  file.write(output)
  file.close
end