Sha256: 3db52e83f29b7e3e02040a8b80a4e8fc4ffd83fa44c9effbbdef3f2d51c3e7f7

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'helper'
require 'stringio'

class MockNotifier < ::RiotNotifier::Base
  def initialize
    super(StringIO.new)
  end

  def notify(color, msg)
    [ color, msg ]
  end
end

context "RiotNotifier" do
  context "with MockNotifier" do
    setup { MockNotifier.new }

    asserts("displays failure in red") { topic.fail("desc", "failed") }.equals([:red, "FAILURE: failed"])
    asserts("displays error in red") { topic.error("desc", "errored") }.equals([:red, "ERROR: errored"])
    asserts("doesn't display results with bad results") do
      topic.report("desc", [:fail, "failure"])
      topic.report("desc", [:error, "error"])
      topic.results(23.0)
    end.nil

    context "displays results without bad results" do
      asserts("in green") do
        topic.results(0.0).first
      end.equals(:green)
      asserts("correctly") do
        topic.results(0.0).last
      end.matches(/0 passes, 0 failures, 0 errors in 0.000000 seconds/)
    end
  end # with MockNotifier

  context "with RedgreenNotifier" do
    setup do
      klass = RiotNotifier::RedgreenNotifier.dup
      klass.class_eval do
        def exec(string)
          string
        end
      end
      klass.new
    end

    asserts("notify green hello world") { topic.notify(:red, "hello world") }.matches(/red "hello world"/)
    asserts("escape <") { topic.notify(:red, "<Topic>") }.matches(/&lt;Topic>/)
    asserts("quote double quotes") { topic.notify(:red, %{"errored"}) }.matches(/\\"errored\\"/)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riot_notifier-0.0.2 test/test_riot_notifier.rb
riot_notifier-0.0.1 test/test_riot_notifier.rb