Class: SauceTest::Runner::Report
- Inherits:
-
Object
- Object
- SauceTest::Runner::Report
- Includes:
- ERB::Util
- Defined in:
- lib/sauce-test/runner/report.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#test_file ⇒ Object
Returns the value of attribute test_file.
Instance Method Summary collapse
- #add_example(group_name, descripton) ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #to_hash ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
12 13 14 15 16 17 18 |
# File 'lib/sauce-test/runner/report.rb', line 12 def initialize @groups = [] @status = 'passed' @count = {'total' => 0, 'pending' => 0, 'failed' => 0} end |
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
10 11 12 |
# File 'lib/sauce-test/runner/report.rb', line 10 def browser @browser end |
#duration ⇒ Object
Returns the value of attribute duration.
10 11 12 |
# File 'lib/sauce-test/runner/report.rb', line 10 def duration @duration end |
#test_file ⇒ Object
Returns the value of attribute test_file.
10 11 12 |
# File 'lib/sauce-test/runner/report.rb', line 10 def test_file @test_file end |
Instance Method Details
#add_example(group_name, descripton) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sauce-test/runner/report.rb', line 20 def add_example(group_name, descripton) descripton['full_name'] = group_name + ' ' + descripton['name'] @count['total'] += 1 status = descripton['status'] @count['pending'] += 1 if status == 'pending' @count['failed'] += 1 if status == 'failed' group = nil @groups.each do |g| if g['name'] == group_name group = g g['examples'] << descripton g['status'] = status if status != 'passed' and g['status'] != 'failed' end end unless group group = {'name' => group_name, 'status' => status, 'examples' => [descripton]} @groups << group end @status = status if status != 'passed' and @status != 'failed' end |
#to_hash ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/sauce-test/runner/report.rb', line 46 def to_hash {'file' => test_file, 'browser' => browser, 'duration' => duration, 'status' => @status, 'count' => @count, 'groups' => @groups} end |
#to_html ⇒ Object
55 56 57 58 59 60 |
# File 'lib/sauce-test/runner/report.rb', line 55 def to_html template_file = File.dirname(__FILE__) + '/../templates/test_report.erb' template_str = IO.readlines(template_file).join template = ERB.new(template_str) template.result(binding) end |