Sha256: 45e8359fac25c33cad7c365dcf158d80ed01209f33e4e928541c707d4bbaeb51

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'teststrap'
require 'stringio'

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

  asserts("success message is stripped if nil") do
    topic.pass("foo", nil)
    @out.string
  end.matches(/\+ \e\[32mfoo\e\[0m\n/)

  asserts("failure message excludes line info if none provided") do
    @out.rewind
    topic.fail("foo", "bar", nil, nil)
    @out.string
  end.matches(/\- \e\[33mfoo: bar\e\[0m\n/)

  context 'reporting on an empty context' do
    setup do
      context = Riot::Context.new('empty context') {
        context("a nested empty context") {}
      }.run(topic)
    end
    should("not output context name") { @out.string }.empty
  end

  context "reporting on a non-empty context" do
    setup do
      Riot::Context.new('supercontext') {
        asserts("truth") { true }
      }.run(topic)
    end

    should('output context name') { @out.string }.matches(/supercontext/)
    should('output name of passed assertion') { @out.string }.matches(/truth/)
  end
end # StoryReporter

context "Plain StoryReporter" do
  setup do
    @out = StringIO.new
    Riot::StoryReporter.new(@out, {"plain" => true})
  end

  asserts("success message is stripped if nil") do
    topic.pass("foo", nil)
    @out.string
  end.matches(/\+ foo\n/)

  asserts("failure message excludes line info if none provided") do
    @out.rewind
    topic.fail("foo", "bar", nil, nil)
    @out.string
  end.matches(/\- foo: bar\n/)
end # Plain StoryReporter

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
riot-0.12.7 test/core/reports/story_reporter_test.rb
riot-0.12.6 test/core/reports/story_reporter_test.rb