Class: SuiteView

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

Overview

SuiteView is responsible for providing consumable Ruby Cucumber suite stats

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SuiteRender::Pie

#launch, #render_pie_chart_html

Constructor Details

#initialize(opts) ⇒ SuiteView

Returns a new instance of SuiteView.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/suiteview.rb', line 10

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(',')
  self.exclude_tag = opts[:exclude_tag]

  # 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
  self
end

Instance Attribute Details

#exclude_tagObject

Returns the value of attribute exclude_tag.



8
9
10
# File 'lib/suiteview.rb', line 8

def exclude_tag
  @exclude_tag
end

#include_tagsObject

Returns the value of attribute include_tags.



8
9
10
# File 'lib/suiteview.rb', line 8

def include_tags
  @include_tags
end

#outputObject

Returns the value of attribute output.



8
9
10
# File 'lib/suiteview.rb', line 8

def output
  @output
end

#render_stepObject

Returns the value of attribute render_step.



8
9
10
# File 'lib/suiteview.rb', line 8

def render_step
  @render_step
end

#repoObject

Returns the value of attribute repo.



8
9
10
# File 'lib/suiteview.rb', line 8

def repo
  @repo
end

Instance Method Details

#outline_tag_count(tag) ⇒ Object



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

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

#percentagesObject



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

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

#renderObject



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

def render
  self.render_step.render
end

#render_to_file(filename) ⇒ Object



61
62
63
# File 'lib/suiteview.rb', line 61

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

#scenario_tag_count(tag) ⇒ Object



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

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

#to_csvObject



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

def to_csv
  self.render_step.to_csv
end

#total_tag_count(tag) ⇒ Object



33
34
35
36
# File 'lib/suiteview.rb', line 33

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

#total_tags_countObject



38
39
40
41
42
43
44
45
# File 'lib/suiteview.rb', line 38

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