Class: SuiteView

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

Overview

SuiteView is responsible for providing consumable Ruby Cucumber suite stats

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ SuiteView



8
9
10
11
12
13
14
15
16
17
# File 'lib/suiteview.rb', line 8

def initialize(opts)
  self.output = nil
  self.repo = CQL::Repository.new(opts[:repo])
  self.include_tags = opts[:include_tags] || ""
  self.include_tags = self.include_tags.split(',')

  # Create a SuiteRender object and set it as the last step in the chain
  self.render_step = SuiteRender.new(self)
  render_step.next_step = self
end

Instance Attribute Details

#include_tagsObject

Returns the value of attribute include_tags.



6
7
8
# File 'lib/suiteview.rb', line 6

def include_tags
  @include_tags
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/suiteview.rb', line 6

def output
  @output
end

#render_stepObject

Returns the value of attribute render_step.



6
7
8
# File 'lib/suiteview.rb', line 6

def render_step
  @render_step
end

#repoObject

Returns the value of attribute repo.



6
7
8
# File 'lib/suiteview.rb', line 6

def repo
  @repo
end

Instance Method Details

#outline_tag_count(tag) ⇒ Object



19
20
21
22
# File 'lib/suiteview.rb', line 19

def outline_tag_count(tag)
  self.output = outline_query(tag).map { |item| item['examples'] }.flatten.count
  self
end

#percentagesObject



43
44
45
46
47
# File 'lib/suiteview.rb', line 43

def percentages
  suite_stat_dto = SuiteStat.new([%w(tag percent)], 0, {})
  self.output = calc_percentage(suite_stat_dto)
  self
end

#renderObject



53
54
55
# File 'lib/suiteview.rb', line 53

def render
  self.render_step.render
end

#render_to_file(filename) ⇒ Object



57
58
59
# File 'lib/suiteview.rb', line 57

def render_to_file(filename)
  self.render_step.render_to_file(filename)
end

#scenario_tag_count(tag) ⇒ Object



24
25
26
27
# File 'lib/suiteview.rb', line 24

def scenario_tag_count(tag)
  self.output = scenario_query(tag).map { |item| item['name'] }.count
  self
end

#to_csvObject



49
50
51
# File 'lib/suiteview.rb', line 49

def to_csv
  self.render_step.to_csv
end

#total_tag_count(tag) ⇒ Object



29
30
31
32
# File 'lib/suiteview.rb', line 29

def total_tag_count(tag)
  self.output = scenario_tag_count(tag).render + outline_tag_count(tag).render
  self
end

#total_tags_countObject



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

def total_tags_count
  output = [%w(tag count)]
  self.include_tags.each do |tag|
    output << [tag, total_tag_count(tag).render.to_s]
  end
  self.output = output
  self
end