Class: Sasspectations::ResultParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(css_output) ⇒ ResultParser

Assumes one spec result per line



9
10
11
# File 'lib/sasspectations/result_parser.rb', line 9

def initialize(css_output)
  @css_output = css_output
end

Instance Attribute Details

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/sasspectations/result_parser.rb', line 5

def result
  @result
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/sasspectations/result_parser.rb', line 24

def failed?
  @result.any? { |r| r.first =~ /f/i }
end

#parseObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/sasspectations/result_parser.rb', line 13

def parse
  spec_lines = @css_output.split("\n").reject! &:empty?
  @result = spec_lines.map do |spec_line|
    if spec_line =~ /{\s*expect\s?:\s?true[;]?\s?}/
      [".".colorize(:green), spec_line]
    else
      ["F".colorize(:red), spec_line]
    end
  end
end