Method: AnySpec::TestRunner#initialize

Defined in:
lib/any-spec/test-runner.rb

#initialize(target_executable, test_specification_file) ⇒ TestRunner

Returns a new instance of TestRunner.

Raises:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/any-spec/test-runner.rb', line 13

def initialize( target_executable, test_specification_file )
  # Verify that the target executable exists and is in the current PATH
  @target_executable = target_executable.strip
  # Load the test specification file
  @test_specification_file = File.expand_path(test_specification_file)
  raise Exception, "The test specification file you supplied does not exist." unless(File.exist? @test_specification_file)
  test_spec = YAML::load_file(@test_specification_file)
  @specification_root = test_spec["specification_root"]
  @specification_extension = test_spec["specification_extension"]
  # Find and load test-case file paths
  @test_case_paths = Dir[File.join(File.split(@test_specification_file)[0], @specification_root, '**',  "*" + @specification_extension)].sort
  # Instantiate the test cases
  @test_cases = @test_case_paths.map do |test_case|
    AnySpec::TestCase.new(test_case, @target_executable)
  end
end