1 require File.dirname(__FILE__) + '/../../../spec_helper'
2 require 'spec/runner/formatter/failing_example_groups_formatter'
7 describe FailingExampleGroupsFormatter do
8 attr_reader :example_group, :formatter, :io
12 options = mock('options')
13 @formatter = FailingExampleGroupsFormatter.new(options, io)
14 @example_group = Class.new(::Spec::Example::ExampleGroup)
17 it "should add example name for each failure" do
18 formatter.add_example_group(Class.new(ExampleGroup).describe("b 1"))
19 formatter.example_failed("e 1", nil, Reporter::Failure.new(nil, RuntimeError.new))
20 formatter.add_example_group(Class.new(ExampleGroup).describe("b 2"))
21 formatter.example_failed("e 2", nil, Reporter::Failure.new(nil, RuntimeError.new))
22 formatter.example_failed("e 3", nil, Reporter::Failure.new(nil, RuntimeError.new))
23 io.string.should == "b 1\nb 2\n"
26 it "should delimit ExampleGroup superclass descriptions with :" do
27 parent_example_group = Class.new(example_group).describe("Parent")
28 child_example_group = Class.new(parent_example_group).describe("#child_method")
29 grand_child_example_group = Class.new(child_example_group).describe("GrandChild")
31 formatter.add_example_group(grand_child_example_group)
32 formatter.example_failed("failure", nil, Reporter::Failure.new(nil, RuntimeError.new))
33 io.string.should == "Parent#child_method GrandChild\n"
36 it "should remove druby url, which is used by Spec::Distributed" do
37 @formatter.add_example_group(Class.new(ExampleGroup).describe("something something (druby://99.99.99.99:99)"))
38 @formatter.example_failed("e 1", nil, Reporter::Failure.new(nil, RuntimeError.new))
39 io.string.should == "something something\n"