Class: Compatriot::Reporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tests) ⇒ Reporter

Returns a new instance of Reporter.



7
8
9
# File 'lib/compatriot/reporter.rb', line 7

def initialize(tests)
  @tests = tests
end

Instance Attribute Details

#testsObject

Returns the value of attribute tests.



5
6
7
# File 'lib/compatriot/reporter.rb', line 5

def tests
  @tests
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
# File 'lib/compatriot/reporter.rb', line 11

def run
  $tests = tests.sort_by {|t| (t.passed? ? 1 : 0) }
  file_path = File.expand_path('../report_template.html.haml', __FILE__)
  template = File.read(file_path)
  engine = Haml::Engine.new(template)
  File.write 'compatriot_report.html',engine.render
end