File: basic_reporter_test.rb

package info (click to toggle)
ruby-riot 0.12.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 512 kB
  • sloc: ruby: 2,557; makefile: 2
file content (72 lines) | stat: -rw-r--r-- 2,030 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'teststrap'

context "A reporter" do
  setup do
    Class.new(Riot::Reporter) do
      def pass(d, message) "passed(#{d}, #{message.inspect})"; end
      def fail(d, message, line, file) "failed(#{d}, #{message} on line #{line} in file #{file})"; end
      def error(d, e) "errored(#{d}, #{e})"; end
      def results(time); end
    end.new
  end

  # pass

  asserts("pass count increase when :pass sent to #report") do
    topic.report("", [:pass])
    topic.passes
  end.equals(1)

  asserts("description sent to #pass") do
    topic.report("hi mom", [:pass])
  end.equals("passed(hi mom, nil)")

  # fail

  asserts("fail count increase when :fail sent to #report") do
    topic.report("", [:fail, ""])
    topic.failures
  end.equals(1)

  asserts("description, message, line and file sent to #fail") do
    topic.report("hi mom", [:fail, "how are you", 4, "foo"])
  end.equals("failed(hi mom, how are you on line 4 in file foo)")

  # error

  asserts("error count increase when :error sent to #report") do
    topic.report("", [:error, ""])
    topic.errors
  end.equals(1)

  asserts("error count increase when :setup_error sent to #report") do
    topic.report("", [:setup_error, ""])
    topic.errors
  end.equals(2)

  asserts("description sent to #error") do
    topic.report("break it down", [:error, "error time"])
  end.equals("errored(break it down, error time)")

  context "instance" do
    setup { Riot::Reporter.new }
    should("return self invoking new") { topic.new }.equals { topic }
    should("accept an options hash") { topic.new({}) }.equals { topic }
  end

  context "with no errors or failures" do
    hookup { topic.report("foo", [:pass, nil]) }
    asserts(:success?)
  end

  context "with failures and no errors" do
    hookup { topic.report("foo", [:fail, "blah"]) }
    asserts(:success?).equals(false)
  end

  context "with errors and no failures" do
    hookup { topic.report("foo", [:error, Exception.new("boogers")]) }
    asserts(:success?).equals(false)
  end
end # A reporter