Class: CucumberMonitor::StepDefinitionFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_monitor/step_definition_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, path) ⇒ StepDefinitionFile

Returns a new instance of StepDefinitionFile.



13
14
15
16
# File 'lib/cucumber_monitor/step_definition_file.rb', line 13

def initialize(file,path)
  @file = file
  @path = path
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/cucumber_monitor/step_definition_file.rb', line 7

def file
  @file
end

#pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/cucumber_monitor/step_definition_file.rb', line 7

def path
  @path
end

Class Method Details

.keywordsObject



9
10
11
# File 'lib/cucumber_monitor/step_definition_file.rb', line 9

def self.keywords
  [I18n.t("given"), I18n.t("when"), I18n.t("then"), I18n.t("and"), I18n.t("but")].collect{|c| c[2..-1]}
end

Instance Method Details

#definitionsObject



29
30
31
32
33
34
35
36
37
# File 'lib/cucumber_monitor/step_definition_file.rb', line 29

def definitions
  df = []
  lines.each_with_index do |line,i|
    if self.class.keywords.any?{|k| line.include?(k)}
      df << Definition.new(line.strip,self,i+1)
    end
  end
  df
end

#linesObject



22
23
24
25
26
27
# File 'lib/cucumber_monitor/step_definition_file.rb', line 22

def lines
  f = open(CucumberMonitor::Base.step_definitions_path + '/' + file)
  file_lines = f.readlines
  f.close
  file_lines
end

#nameObject



18
19
20
# File 'lib/cucumber_monitor/step_definition_file.rb', line 18

def name
  file[0..-9]
end