Class: CucumberMonitor::Context

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, feature) ⇒ Context

Returns a new instance of Context.



9
10
11
12
13
# File 'lib/cucumber_monitor/context.rb', line 9

def initialize(name,feature)
  @name = name
  @keyword = I18n.t("background")
  @feature = feature
end

Instance Attribute Details

#featureObject

Returns the value of attribute feature.



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

def feature
  @feature
end

#keywordObject

Returns the value of attribute keyword.



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

def keyword
  @keyword
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#stepsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cucumber_monitor/context.rb', line 15

def steps
  st = []
  started = false
  stopped = false
  record = false
  count = 0
  feature.lines.each_with_index do |line, i|
    if line.include?(keyword)
      started = true
    end
    if started && !stopped
      st << Step.new(line.strip, self, i+1) unless (count == 0 || line.strip.blank?)
      stopped = true if line.strip.blank?
      count += 1
    end
  end
  st
end