Class: Gauntlt::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/gauntlt/runtime.rb

Defined Under Namespace

Classes: ExecutionFailed, NoFilesFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, tags = [], format = "") ⇒ Runtime

Returns a new instance of Runtime

Raises:


14
15
16
17
18
19
20
# File 'lib/gauntlt/runtime.rb', line 14

def initialize(path, tags=[], format="")
  self.path         = path
  self.attack_files = self.class.attack_files_for(path)
  self.tags         = tags
  self.format       = format
  raise NoFilesFound.new("No files found in path: #{path}") if attack_files.empty?
end

Instance Attribute Details

#attack_filesObject

Returns the value of attribute attack_files


12
13
14
# File 'lib/gauntlt/runtime.rb', line 12

def attack_files
  @attack_files
end

#formatObject

Returns the value of attribute format


12
13
14
# File 'lib/gauntlt/runtime.rb', line 12

def format
  @format
end

#pathObject

Returns the value of attribute path


12
13
14
# File 'lib/gauntlt/runtime.rb', line 12

def path
  @path
end

#tagsObject

Returns the value of attribute tags


12
13
14
# File 'lib/gauntlt/runtime.rb', line 12

def tags
  @tags
end

Class Method Details

.adapters_dirObject


55
56
57
# File 'lib/gauntlt/runtime.rb', line 55

def adapters_dir
  File.join(base_dir, "attack_adapters")
end

.attack_files_for(path) ⇒ Object


47
48
49
# File 'lib/gauntlt/runtime.rb', line 47

def attack_files_for(path)
  path.split(' ').map{|p| Dir.glob(p)}.flatten
end

.base_dirObject


51
52
53
# File 'lib/gauntlt/runtime.rb', line 51

def base_dir
  File.expand_path( File.dirname(__FILE__) )
end

.cuke_runtime(*args) ⇒ Object


43
44
45
# File 'lib/gauntlt/runtime.rb', line 43

def cuke_runtime(*args)
  self.new(*args).cuke_runtime
end

Instance Method Details

#cuke_cliObject


22
23
24
25
26
27
28
# File 'lib/gauntlt/runtime.rb', line 22

def cuke_cli
  args =  attack_files + ['--strict', '--no-snippets', '--require', self.class.adapters_dir]
  args += ['--tags', tags] unless tags.empty?
  args += ['--format', format] unless format.nil?

  Cucumber::Cli::Main.new(args)
end

#cuke_configObject


30
31
32
# File 'lib/gauntlt/runtime.rb', line 30

def cuke_config
  cli.config
end

#cuke_runtimeObject


34
35
36
# File 'lib/gauntlt/runtime.rb', line 34

def cuke_runtime
  Cucumber::Runtime.new(cuke_cli.configuration)
end

#execute!Object


38
39
40
# File 'lib/gauntlt/runtime.rb', line 38

def execute!
  cuke_cli.execute! 
end