Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / rspec / spec / spec / runner / formatter / specdoc_formatter_spec.rb
blobbea10b53b7f41a2fb9cafb661595d4401098f601
1 require File.dirname(__FILE__) + '/../../../spec_helper.rb'
3 module Spec
4   module Runner
5     module Formatter
6       describe "SpecdocFormatter" do
7         before(:each) do
8           @io = StringIO.new
9           @options = mock('options')
10           @options.stub!(:dry_run).and_return(false)
11           @options.stub!(:colour).and_return(false)
12           @formatter = SpecdocFormatter.new(@options, @io)
13           @behaviour = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples")
14         end
16         it "should produce standard summary without pending when pending has a 0 count" do
17           @formatter.dump_summary(3, 2, 1, 0)
18           @io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
19         end
21         it "should produce standard summary" do
22           @formatter.dump_summary(3, 2, 1, 4)
23           @io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n")
24         end
26         it "should push context name" do
27           @formatter.add_example_group(Spec::Example::ExampleGroupDescription.new("context"))
28           @io.string.should eql("\ncontext\n")
29         end
31         it "when having an error, should push failing spec name and failure number" do
32           @formatter.example_failed(
33             @behaviour.it("spec"),
34             98,
35             Reporter::Failure.new("c s", RuntimeError.new)
36           )
37           @io.string.should eql("- spec (ERROR - 98)\n")
38         end
40         it "when having an expectation failure, should push failing spec name and failure number" do
41           @formatter.example_failed(
42             @behaviour.it("spec"),
43             98,
44             Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
45           )
46           @io.string.should eql("- spec (FAILED - 98)\n")
47         end
49         it "should push nothing on start" do
50           @formatter.start(5)
51           @io.string.should eql("")
52         end
54         it "should push nothing on start dump" do
55           @formatter.start_dump
56           @io.string.should eql("")
57         end
59         it "should push passing spec name" do
60           @formatter.example_passed(@behaviour.it("spec"))
61           @io.string.should eql("- spec\n")
62         end
64         it "should push pending example name and message" do
65           @formatter.example_pending('behaviour', 'example','reason')
66           @io.string.should eql("- example (PENDING: reason)\n")
67         end
69         it "should dump pending" do
70           @formatter.example_pending('behaviour', 'example','reason')
71           @io.rewind
72           @formatter.dump_pending
73           @io.string.should =~ /Pending\:\nbehaviour example \(reason\)\n/
74         end
76         it "should not produce summary on dry run" do
77           @options.should_receive(:dry_run).and_return(true)
78           @formatter.dump_summary(3, 2, 1, 0)
79           @io.string.should eql("")
80         end
81       end
82     end
83   end
84 end