Sha256: ac534e4979a74f9df1c8a0f063335a119057d5dfb2e9b03cffab550c23bc9339

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'teststrap'

context "DotMatrixReporter" do
  setup do
    @out = StringIO.new
    Riot::DotMatrixReporter.new(@out)
  end

  context "with a passing test" do
    setup do
      context = Riot::Context.new('whatever') do
        asserts('true') { true }
      end
      context.run(topic)
      @out.string
    end
    asserts_topic('puts a dot').matches('.')
  end

  context 'with a failing test' do
    setup do
      Riot::Context.new('whatever') do
        asserts('nope!') { false }
      end.run(topic)
      topic.results(100)
      @out.string
    end

    asserts_topic('puts an F').matches('F')
    asserts_topic("puts the full context + assertion name").matches('whatever asserts nope!')
    asserts_topic("puts the failure reason").matches(/Expected .* but got false instead/)
  end

  context 'with an error test' do
    setup do
      Riot::Context.new('whatever') do
        asserts('bang') { raise "BOOM" }
      end.run(topic)
      topic.results(100)
      @out.string
    end

    asserts_topic('puts an E').matches('E')
    asserts_topic('puts the full context + assertion name').matches('whatever asserts bang')
    asserts_topic('puts the exception message').matches('BOOM')
    # <file path>:<one or more number><two newlines><anything till end of line><newline> is the last thing in the stack trace
    asserts_topic('puts the filtered exception backtrace').matches(/#{__FILE__}:\d+:[^\n]*\n\n.*$\n\z/)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riot-0.12.5 test/core/reports/dot_matrix_reporter_test.rb