Class: Jasmine::Headless::Report

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jasmine/headless/report.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Report

Returns a new instance of Report.



18
19
20
# File 'lib/jasmine/headless/report.rb', line 18

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



16
17
18
# File 'lib/jasmine/headless/report.rb', line 16

def file
  @file
end

#reportObject (readonly)

Returns the value of attribute report.



16
17
18
# File 'lib/jasmine/headless/report.rb', line 16

def report
  @report
end

Class Method Details

.load(file) ⇒ Object



11
12
13
# File 'lib/jasmine/headless/report.rb', line 11

def load(file)
  new(file).process
end

Instance Method Details

#failed_filesObject



57
58
59
60
61
# File 'lib/jasmine/headless/report.rb', line 57

def failed_files
  @report.find_all { |entry| 
    entry.kind_of?(Jasmine::Headless::ReportMessage::Fail)
  }.collect(&:filename).uniq.compact
end

#has_failed_on?(statement) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/jasmine/headless/report.rb', line 45

def has_failed_on?(statement)
  @report.any? { |entry| 
    if entry.kind_of?(Jasmine::Headless::ReportMessage::Fail)
      entry.statement == statement
    end
  }
end

#has_used_console?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/jasmine/headless/report.rb', line 41

def has_used_console?
  @report.any? { |entry| entry.kind_of?(Jasmine::Headless::ReportMessage::Console) }
end

#processObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jasmine/headless/report.rb', line 22

def process
  last_message = nil
  @report = File.readlines(file).collect do |line|
    type, *parts = line.split('||', -1)

    if !(report_klass = report_class_for(type))
      if last_message.kind_of?(Jasmine::Headless::ReportMessage::Console)
        last_message.message << "\n"
        last_message.message << line.strip
      end
    else
      parts.last.strip!

      last_message = report_klass.new_from_parts(parts)
    end
  end
  self
end

#valid?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/jasmine/headless/report.rb', line 53

def valid?
  last_total != nil
end