rspec-extra-formatters 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2010, Diego Souza
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name of the <ORGANIZATION> nor the names of its contributors
13
+ may be used to endorse or promote products derived from this software
14
+ without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.rst ADDED
@@ -0,0 +1,48 @@
1
+ ================
2
+ RSpec Formatters
3
+ ================
4
+
5
+ ::
6
+
7
+ $ rake format=tap
8
+ ok 1 - TapFormatter should initialize the counter to 0
9
+ ok 2 - TapFormatter example_passed should increment the counter and use the full_description attribute
10
+ ok 3 - TapFormatter example_failed should increment the counter and use the full_description attribute
11
+ ok 4 - TapFormatter example_pending should do the same as example_failed
12
+ ok 5 - TapFormatter dump_summary should print the number of tests if there were tests
13
+ ok 6 - TapFormatter dump_summary should print nothing if there were not tests
14
+ ok 7 - JUnitFormatter should initialize the tests with failures and success
15
+ ok 8 - JUnitFormatter example_passed should push the example obj into success list
16
+ ok 9 - JUnitFormatter example_failed should push the example obj into failures list
17
+ ok 10 - JUnitFormatter example_pending should do the same as example_failed
18
+ ok 11 - JUnitFormatter read_failure should ignore if there is no exception
19
+ ok 12 - JUnitFormatter read_failure should read message and backtrace from the example
20
+ ok 13 - JUnitFormatter dump_summary should print the junit xml
21
+ 1..13
22
+
23
+ ::
24
+
25
+ $ rake format=junit
26
+ <?xml version="1.0" encoding="utf-8" ?>
27
+ <testsuite errors="0" failures="0" tests="13" time="0.019992" timestamp="2011-01-21T23:07:41-02:00">
28
+ <properties />
29
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/tap_formatter_spec.rb" name="TapFormatter should initialize the counter to 0" time="0.001298" />
30
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/tap_formatter_spec.rb" name="TapFormatter example_passed should increment the counter and use the full_description attribute" time="0.001546" />
31
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/tap_formatter_spec.rb" name="TapFormatter example_failed should increment the counter and use the full_description attribute" time="0.001427" />
32
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/tap_formatter_spec.rb" name="TapFormatter example_pending should do the same as example_failed" time="0.001456" />
33
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/tap_formatter_spec.rb" name="TapFormatter dump_summary should print the number of tests if there were tests" time="0.00177" />
34
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/tap_formatter_spec.rb" name="TapFormatter dump_summary should print nothing if there were not tests" time="0.000398" />
35
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter should initialize the tests with failures and success" time="0.000859" />
36
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter example_passed should push the example obj into success list" time="0.000829" />
37
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter example_failed should push the example obj into failures list" time="0.000778" />
38
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter example_pending should do the same as example_failed" time="0.000758" />
39
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter read_failure should ignore if there is no exception" time="0.00119" />
40
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter read_failure should read message and backtrace from the example" time="0.001823" />
41
+ <testcase classname="/home/dsouza/dev/github/rspec_formatters/spec/junit_formatter_spec.rb" name="JUnitFormatter dump_summary should print the junit xml" time="0.003813" />
42
+ </testsuite>
43
+
44
+ Using it
45
+ ========
46
+
47
+ Make sure you add `-r "rspec-extra-formatters"` to rspec options and both `-f JUnitFormatter` and `-f TapFormatter` should work. :-)
48
+
@@ -0,0 +1,2 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/rspec-extra-formatters/junit_formatter.rb")
2
+ require File.expand_path(File.dirname(__FILE__) + "/rspec-extra-formatters/tap_formatter")
@@ -0,0 +1,88 @@
1
+ # -*- encoding : utf-8 -*-
2
+ #
3
+ # Copyright (c) 2011, Diego Souza
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ # * Neither the name of the <ORGANIZATION> nor the names of its contributors
15
+ # may be used to endorse or promote products derived from this software
16
+ # without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ require "time"
30
+ require "rspec/core/formatters/base_formatter"
31
+
32
+ class JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
33
+
34
+ attr_reader :test_results
35
+
36
+ def initialize(output)
37
+ super(output)
38
+ @test_results = { :failures => [], :successes => [] }
39
+ end
40
+
41
+ def example_passed(example)
42
+ super(example)
43
+ @test_results[:successes].push(example)
44
+ end
45
+
46
+ def example_pending(example)
47
+ self.example_failed(example)
48
+ end
49
+
50
+ def example_failed(example)
51
+ super(example)
52
+ @test_results[:failures].push(example)
53
+ end
54
+
55
+ def read_failure(t)
56
+ exception = t.metadata[:execution_result][:exception_encountered] || t.metadata[:execution_result][:exception]
57
+ message = ""
58
+ unless (exception.nil?)
59
+ message = exception.message
60
+ message += "\n"
61
+ message += format_backtrace(exception.backtrace, t).join("\n")
62
+ end
63
+ return(message)
64
+ end
65
+
66
+ def dump_summary(duration, example_count, failure_count, pending_count)
67
+ super(duration, example_count, failure_count, pending_count)
68
+ output.puts("<?xml version=\"1.0\" encoding=\"utf-8\" ?>")
69
+ output.puts("<testsuite errors=\"0\" failures=\"#{failure_count+pending_count}\" tests=\"#{example_count}\" time=\"#{duration}\" timestamp=\"#{Time.now.iso8601}\">")
70
+ output.puts(" <properties />")
71
+ @test_results[:successes].each do |t|
72
+ md = t.metadata
73
+ runtime = md[:execution_result][:run_time]
74
+ output.puts(" <testcase classname=\"#{md[:file_path]}\" name=\"#{md[:full_description]}\" time=\"#{runtime}\" />")
75
+ end
76
+ @test_results[:failures].each do |t|
77
+ md = t.metadata
78
+ runtime = md[:execution_result][:run_time]
79
+ output.puts(" <testcase classname=\"#{md[:file_path]}\" name=\"#{md[:full_description]}\" time=\"#{runtime}\">")
80
+ output.puts(" <failure message=\"failure\" type=\"failure\">")
81
+ output.puts("<![CDATA[ #{read_failure(t)} ]]>")
82
+ output.puts(" </failure>")
83
+ output.puts(" </testcase>")
84
+ end
85
+ output.puts("</testsuite>")
86
+ end
87
+
88
+ end
@@ -0,0 +1,63 @@
1
+ # -*- encoding : utf-8 -*-
2
+ #
3
+ # Copyright (c) 2011, Diego Souza
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ # * Neither the name of the <ORGANIZATION> nor the names of its contributors
15
+ # may be used to endorse or promote products derived from this software
16
+ # without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ require "rspec/core/formatters/base_formatter"
30
+
31
+ class TapFormatter < RSpec::Core::Formatters::BaseFormatter
32
+
33
+ attr_reader :total
34
+
35
+ def initialize(output)
36
+ super(output)
37
+ @total = 0
38
+ end
39
+
40
+ def example_passed(example)
41
+ super(example)
42
+ @total += 1
43
+ output.puts("ok #{@total} - #{example.metadata[:full_description]}")
44
+ end
45
+
46
+ def example_pending(example)
47
+ self.example_failed(example)
48
+ end
49
+
50
+ def example_failed(example)
51
+ super(example)
52
+ @total += 1
53
+ output.puts("not ok #{@total} - #{example.metadata[:full_description]}")
54
+ end
55
+
56
+ def dump_summary(duration, example_count, failure_count, pending_count)
57
+ super(duration, example_count, failure_count, pending_count)
58
+ if (@total > 0)
59
+ output.puts("1..#{example_count}")
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,150 @@
1
+ # -*- encoding : utf-8 -*-
2
+ #
3
+ # Copyright (c) 2011, Diego Souza
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ # * Neither the name of the <ORGANIZATION> nor the names of its contributors
15
+ # may be used to endorse or promote products derived from this software
16
+ # without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb")
30
+
31
+ describe JUnitFormatter do
32
+
33
+ before(:each) do
34
+ @output = mock("output")
35
+ end
36
+
37
+ it "should initialize the tests with failures and success" do
38
+ JUnitFormatter.new(@output).test_results.should eql({:failures=>[], :successes=>[]})
39
+ end
40
+
41
+ describe "example_passed" do
42
+
43
+ it "should push the example obj into success list" do
44
+ f = JUnitFormatter.new(@output)
45
+ f.example_passed("foobar")
46
+ f.test_results[:successes].should eql(["foobar"])
47
+ end
48
+
49
+ end
50
+
51
+ describe "example_failed" do
52
+
53
+ it "should push the example obj into failures list" do
54
+ f = JUnitFormatter.new(@output)
55
+ f.example_failed("foobar")
56
+ f.test_results[:failures].should eql(["foobar"])
57
+ end
58
+
59
+ end
60
+
61
+ describe "example_pending" do
62
+
63
+ it "should do the same as example_failed" do
64
+ f = JUnitFormatter.new(@output)
65
+ f.example_pending("foobar")
66
+ f.test_results[:failures].should eql(["foobar"])
67
+ end
68
+
69
+ end
70
+
71
+ describe "read_failure" do
72
+
73
+ it "should ignore if there is no exception" do
74
+ example = mock("example")
75
+ example.should_receive(:metadata).exactly(2).times.and_return({:execution_result => { :exception_encountered => nil \
76
+ , :exception => nil \
77
+ }})
78
+ f = JUnitFormatter.new(@output)
79
+ f.read_failure(example).should eql("")
80
+ end
81
+
82
+ it "should attempt to read exception if exception encountered is nil" do
83
+ strace = mock("stacktrace")
84
+ strace.should_receive(:message).and_return("foobar")
85
+ strace.should_receive(:backtrace).and_return(["foo","bar"])
86
+
87
+ example = mock("example")
88
+ example.should_receive(:metadata).exactly(3).times.and_return({:execution_result => { :exception_encountered => nil \
89
+ , :exception => strace \
90
+ }})
91
+
92
+ f = JUnitFormatter.new(@output)
93
+ f.read_failure(example).should eql("foobar\nfoo\nbar")
94
+ end
95
+
96
+ it "should read message and backtrace from the example" do
97
+ strace = mock("stacktrace")
98
+ strace.should_receive(:message).and_return("foobar")
99
+ strace.should_receive(:backtrace).and_return(["foo","bar"])
100
+
101
+ example = mock("example")
102
+ example.should_receive(:metadata).exactly(2).times.and_return({:execution_result => {:exception_encountered => strace}})
103
+
104
+ f = JUnitFormatter.new(@output)
105
+ f.read_failure(example).should eql("foobar\nfoo\nbar")
106
+ end
107
+
108
+ end
109
+
110
+ describe "dump_summary" do
111
+
112
+ it "should print the junit xml" do
113
+ strace = mock("stacktrace")
114
+ strace.should_receive(:message).and_return("foobar")
115
+ strace.should_receive(:backtrace).and_return(["foo","bar"])
116
+
117
+ example0 = mock("example-0")
118
+ example1 = mock("example-1")
119
+ example0.should_receive(:metadata).and_return({ :full_description => "foobar-success" \
120
+ , :file_path => "lib/foobar-s.rb" \
121
+ , :execution_result => { :run_time => 0.1 } \
122
+ })
123
+
124
+ example1.should_receive(:metadata).exactly(3).times.and_return({ :full_description => "foobar-failure" \
125
+ , :file_path => "lib/foobar-f.rb" \
126
+ , :execution_result => { :exception_encountered => strace \
127
+ , :run_time => 0.1 \
128
+ }
129
+ })
130
+
131
+ @output.should_receive(:puts).with("<?xml version=\"1.0\" encoding=\"utf-8\" ?>")
132
+ @output.should_receive(:puts).with("<testsuite errors=\"0\" failures=\"1\" tests=\"2\" time=\"0.1\" timestamp=\"#{Time.now.iso8601}\">")
133
+ @output.should_receive(:puts).with(" <properties />")
134
+ @output.should_receive(:puts).with(" <testcase classname=\"lib/foobar-s.rb\" name=\"foobar-success\" time=\"0.1\" />")
135
+ @output.should_receive(:puts).with(" <testcase classname=\"lib/foobar-f.rb\" name=\"foobar-failure\" time=\"0.1\">")
136
+ @output.should_receive(:puts).with(" <failure message=\"failure\" type=\"failure\">")
137
+ @output.should_receive(:puts).with("<![CDATA[ foobar\nfoo\nbar ]]>")
138
+ @output.should_receive(:puts).with(" </failure>")
139
+ @output.should_receive(:puts).with(" </testcase>")
140
+ @output.should_receive(:puts).with("</testsuite>")
141
+
142
+ f = JUnitFormatter.new(@output)
143
+ f.example_passed(example0)
144
+ f.example_failed(example1)
145
+ f.dump_summary("0.1", 2, 1, 0)
146
+ end
147
+
148
+ end
149
+
150
+ end
@@ -0,0 +1,111 @@
1
+ # -*- encoding : utf-8 -*-
2
+ #
3
+ # Copyright (c) 2011, Diego Souza
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright notice,
10
+ # this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ # * Neither the name of the <ORGANIZATION> nor the names of its contributors
15
+ # may be used to endorse or promote products derived from this software
16
+ # without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb")
30
+
31
+ describe TapFormatter do
32
+
33
+ before(:each) do
34
+ @output = mock("output")
35
+ end
36
+
37
+ it "should initialize the counter to 0" do
38
+ TapFormatter.new(@output).total.should eql(0)
39
+ end
40
+
41
+ describe "example_passed" do
42
+
43
+ it "should increment the counter and use the full_description attribute" do
44
+ example = mock("example")
45
+ example.should_receive(:metadata).and_return({:full_description => "foobar"})
46
+ @output.should_receive(:puts).with("ok 1 - foobar")
47
+
48
+ f = TapFormatter.new(@output)
49
+ f.example_passed(example)
50
+
51
+ f.total.should eql(1)
52
+ end
53
+
54
+ end
55
+
56
+ describe "example_failed" do
57
+
58
+ it "should increment the counter and use the full_description attribute" do
59
+ example = mock("example")
60
+ example.should_receive(:metadata).and_return({:full_description => "foobar"})
61
+ @output.should_receive(:puts).with("not ok 1 - foobar")
62
+
63
+ f = TapFormatter.new(@output)
64
+ f.example_failed(example)
65
+
66
+ f.total.should eql(1)
67
+ end
68
+ end
69
+
70
+ describe "example_pending" do
71
+
72
+ it "should do the same as example_failed" do
73
+ example = mock("example")
74
+ example.should_receive(:metadata).and_return({:full_description => "foobar"})
75
+ @output.should_receive(:puts).with("not ok 1 - foobar")
76
+
77
+ f = TapFormatter.new(@output)
78
+ f.example_pending(example)
79
+
80
+ f.total.should eql(1)
81
+ end
82
+
83
+ end
84
+
85
+ describe "dump_summary" do
86
+
87
+ it "should print the number of tests if there were tests" do
88
+ example = mock("example")
89
+ example.should_receive(:metadata).and_return({:full_description => "foobar"})
90
+ example.should_receive(:metadata).and_return({:full_description => "foobar"})
91
+ example.should_receive(:metadata).and_return({:full_description => "foobar"})
92
+ @output.should_receive(:puts).with("ok 1 - foobar")
93
+ @output.should_receive(:puts).with("not ok 2 - foobar")
94
+ @output.should_receive(:puts).with("not ok 3 - foobar")
95
+ @output.should_receive(:puts).with("1..3")
96
+
97
+ f = TapFormatter.new(@output)
98
+ f.example_passed(example)
99
+ f.example_failed(example)
100
+ f.example_pending(example)
101
+ f.dump_summary(0.1, 3, 1, 1)
102
+ end
103
+
104
+ it "should print nothing if there were not tests" do
105
+ f = TapFormatter.new(@output)
106
+ f.dump_summary(0, 0, 0, 0)
107
+ end
108
+
109
+ end
110
+
111
+ end
@@ -0,0 +1,2 @@
1
+ require "rspec"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/rspec-extra-formatters.rb")
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-extra-formatters
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.1"
6
+ platform: ruby
7
+ authors:
8
+ - Diego Souza
9
+ - "Flor\xC3\xA9al TOUMIKIAN"
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-05-26 00:00:00 -03:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rspec
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0"
26
+ type: :development
27
+ version_requirements: *id001
28
+ description: " rspec-extra-formatters Provides TAP and JUnit formatters for rspec\n"
29
+ email: dsouza+rspec-extra-formatters@bitforest.org
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - LICENSE
36
+ - README.rst
37
+ files:
38
+ - lib/rspec-extra-formatters/tap_formatter.rb
39
+ - lib/rspec-extra-formatters/junit_formatter.rb
40
+ - lib/rspec-extra-formatters.rb
41
+ - spec/rspec-extra-formatters/junit_formatter_spec.rb
42
+ - spec/rspec-extra-formatters/tap_formatter_spec.rb
43
+ - spec/spec_helper.rb
44
+ - LICENSE
45
+ - README.rst
46
+ has_rdoc: true
47
+ homepage: http://dsouza.bitforest.org/2011/01/22/rspec-tap-and-junit-formatters/
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.6.2
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: TAP and JUnit formatters for rspec
74
+ test_files:
75
+ - spec/rspec-extra-formatters/junit_formatter_spec.rb
76
+ - spec/rspec-extra-formatters/tap_formatter_spec.rb
77
+ - spec/spec_helper.rb