Module: PropCheck::Property::OutputFormatter

Extended by:
OutputFormatter
Included in:
OutputFormatter
Defined in:
lib/prop_check/property/output_formatter.rb

Instance Method Summary collapse

Instance Method Details

#post_output(output, n_shrink_steps, shrunken_result, shrunken_exception) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/prop_check/property/output_formatter.rb', line 21

def post_output(output, n_shrink_steps, shrunken_result, shrunken_exception)
  if n_shrink_steps == 0
    output.puts '(shrinking impossible)'
  else
    output.puts ''
    output.puts "Shrunken input (after #{n_shrink_steps} shrink steps):"
    output.puts "`#{print_roots(shrunken_result)}`"
    output.puts ""
    output.puts "Shrunken exception:\n---\n#{shrunken_exception}"
    output.puts "---"
    output.puts ""
  end
  output
end

#pre_output(output, n_successful, generated_root, problem) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/prop_check/property/output_formatter.rb', line 8

def pre_output(output, n_successful, generated_root, problem)
  output.puts ""
  output.puts "(after #{n_successful} successful property test runs)"
  output.puts "Failed on: "
  output.puts "`#{print_roots(generated_root)}`"
  output.puts ""
  output.puts "Exception message:\n---\n#{problem}"
  output.puts "---"
  output.puts ""

  output
end


36
37
38
39
40
41
42
43
44
45
# File 'lib/prop_check/property/output_formatter.rb', line 36

def print_roots(lazy_tree_val)
  data =
    if lazy_tree_val.is_a?(Array) && lazy_tree_val.length == 1 && lazy_tree_val[0].is_a?(Hash)
      lazy_tree_val[0]
    else
      lazy_tree_val
    end

  PP.pp(data, '')
end