Class: CucumberMonitor::FeatureFile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ FeatureFile

Returns a new instance of FeatureFile.



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

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#contextsObject



48
49
50
51
52
53
54
55
56
# File 'lib/cucumber_monitor/feature_file.rb', line 48

def contexts
  cont = []
  lines.each do |line|
    if line.include?(I18n.t("background"))
      cont << Context.new(line.clean,self.class.new(file))
    end
  end
  cont
end

#descriptionObject



24
25
26
27
28
29
30
31
32
# File 'lib/cucumber_monitor/feature_file.rb', line 24

def description
  desc = ""
  lines.each do |line|
    if line.include?(I18n.t("feature"))
      desc = line.clean
    end
  end
  desc
end

#linesObject



17
18
19
20
21
22
# File 'lib/cucumber_monitor/feature_file.rb', line 17

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

#nameObject



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

def name
  file[0..-9]
end

#scenariosObject



34
35
36
37
38
39
40
41
42
# File 'lib/cucumber_monitor/feature_file.rb', line 34

def scenarios
  scen = []
  lines.each do |line|
    if line.include?(I18n.t("scenario"))
      scen << Scenario.new(line.clean,self.class.new(file))
    end
  end
  scen
end

#scenarios_namesObject



44
45
46
# File 'lib/cucumber_monitor/feature_file.rb', line 44

def scenarios_names
  scenarios.map(&:name)
end