rspec-extra-formatters 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rst CHANGED
@@ -8,7 +8,7 @@ RSpec Formatters
8
8
  ok 1 - TapFormatter should initialize the counter to 0
9
9
  ok 2 - TapFormatter example_passed should increment the counter and use the full_description attribute
10
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
11
+ ok 4 - TapFormatter example_pending should do the same as example_failed with TODO comment
12
12
  ok 5 - TapFormatter dump_summary should print the number of tests if there were tests
13
13
  ok 6 - TapFormatter dump_summary should print nothing if there were not tests
14
14
  ok 7 - JUnitFormatter should initialize the tests with failures and success
@@ -35,7 +35,7 @@ class JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
35
35
 
36
36
  def initialize(output)
37
37
  super(output)
38
- @test_results = { :failures => [], :successes => [] }
38
+ @test_results = { :failures => [], :successes => [], :skipped => [] }
39
39
  end
40
40
 
41
41
  def example_passed(example)
@@ -44,7 +44,8 @@ class JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
44
44
  end
45
45
 
46
46
  def example_pending(example)
47
- self.example_failed(example)
47
+ super(example)
48
+ @test_results[:skipped].push(example)
48
49
  end
49
50
 
50
51
  def example_failed(example)
@@ -66,7 +67,7 @@ class JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
66
67
  def dump_summary(duration, example_count, failure_count, pending_count)
67
68
  super(duration, example_count, failure_count, pending_count)
68
69
  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("<testsuite errors=\"0\" failures=\"#{failure_count}\" skipped=\"#{pending_count}\" tests=\"#{example_count}\" time=\"#{duration}\" timestamp=\"#{Time.now.iso8601}\">")
70
71
  output.puts(" <properties />")
71
72
  @test_results[:successes].each do |t|
72
73
  md = t.metadata
@@ -86,6 +87,15 @@ class JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
86
87
  output.puts(" </failure>")
87
88
  output.puts(" </testcase>")
88
89
  end
90
+ @test_results[:skipped].each do |t|
91
+ md = t.metadata
92
+ description = _xml_escape(md[:full_description])
93
+ file_path = _xml_escape(md[:file_path])
94
+ runtime = md[:execution_result][:run_time]
95
+ output.puts(" <testcase classname=\"#{file_path}\" name=\"#{description}\" time=\"#{runtime}\">")
96
+ output.puts(" <skipped/>")
97
+ output.puts(" </testcase>")
98
+ end
89
99
  output.puts("</testsuite>")
90
100
  end
91
101
 
@@ -32,6 +32,10 @@ class TapFormatter < RSpec::Core::Formatters::BaseFormatter
32
32
 
33
33
  attr_reader :total
34
34
 
35
+ OK = 'ok'
36
+ NOT_OK = 'not ok'
37
+ TODO = '# TODO '
38
+
35
39
  def initialize(output)
36
40
  super(output)
37
41
  @total = 0
@@ -39,18 +43,17 @@ class TapFormatter < RSpec::Core::Formatters::BaseFormatter
39
43
 
40
44
  def example_passed(example)
41
45
  super(example)
42
- @total += 1
43
- output.puts("ok #{@total} - #{example.metadata[:full_description]}")
46
+ tap_example_output(OK, example)
44
47
  end
45
48
 
46
49
  def example_pending(example)
47
- self.example_failed(example)
50
+ super(example)
51
+ tap_example_output(NOT_OK, example, TODO)
48
52
  end
49
53
 
50
54
  def example_failed(example)
51
55
  super(example)
52
- @total += 1
53
- output.puts("not ok #{@total} - #{example.metadata[:full_description]}")
56
+ tap_example_output(NOT_OK, example)
54
57
  end
55
58
 
56
59
  def dump_summary(duration, example_count, failure_count, pending_count)
@@ -60,4 +63,10 @@ class TapFormatter < RSpec::Core::Formatters::BaseFormatter
60
63
  end
61
64
  end
62
65
 
66
+ private
67
+ def tap_example_output(ok, example, modifier='')
68
+ @total += 1
69
+ output.puts("#{ok} #{@total} - #{modifier}#{example.metadata[:full_description]}")
70
+ end
71
+
63
72
  end
@@ -37,7 +37,7 @@ describe JUnitFormatter do
37
37
  end
38
38
 
39
39
  it "should initialize the tests with failures and success" do
40
- JUnitFormatter.new(StringIO.new).test_results.should eql({:failures=>[], :successes=>[]})
40
+ JUnitFormatter.new(StringIO.new).test_results.should eql({:failures=>[], :successes=>[], :skipped=>[]})
41
41
  end
42
42
 
43
43
  describe "example_passed" do
@@ -62,10 +62,10 @@ describe JUnitFormatter do
62
62
 
63
63
  describe "example_pending" do
64
64
 
65
- it "should do the same as example_failed" do
65
+ it "should push the example obj into the skipped list" do
66
66
  f = JUnitFormatter.new(StringIO.new)
67
67
  f.example_pending("foobar")
68
- f.test_results[:failures].should eql(["foobar"])
68
+ f.test_results[:skipped].should eql(["foobar"])
69
69
  end
70
70
 
71
71
  end
@@ -129,16 +129,24 @@ describe JUnitFormatter do
129
129
  , :run_time => 0.1 \
130
130
  }
131
131
  })
132
+
133
+ example2 = mock("example-2")
134
+ example2.should_receive(:metadata).and_return({ :full_description => "foobar-pending" \
135
+ , :file_path => "lib/foobar-s.rb" \
136
+ , :execution_result => { :run_time => 0.1 } \
137
+ })
138
+
132
139
 
133
140
  output = StringIO.new
134
141
  f = JUnitFormatter.new(output)
135
142
  f.example_passed(example0)
136
143
  f.example_failed(example1)
137
- f.dump_summary("0.1", 2, 1, 0)
144
+ f.example_pending(example2)
145
+ f.dump_summary("0.1", 3, 1, 1)
138
146
 
139
147
  output.string.should == <<-EOF
140
148
  <?xml version="1.0" encoding="utf-8" ?>
141
- <testsuite errors="0" failures="1" tests="2" time="0.1" timestamp="#{@now.iso8601}">
149
+ <testsuite errors="0" failures="1" skipped="1" tests="3" time="0.1" timestamp="#{@now.iso8601}">
142
150
  <properties />
143
151
  <testcase classname="lib/foobar-s.rb" name="foobar-success" time="0.1" />
144
152
  <testcase classname="lib/foobar-f.rb" name="foobar-failure" time="0.1">
@@ -146,6 +154,9 @@ describe JUnitFormatter do
146
154
  <![CDATA[ foobar\nfoo\nbar ]]>
147
155
  </failure>
148
156
  </testcase>
157
+ <testcase classname="lib/foobar-s.rb" name="foobar-pending" time="0.1">
158
+ <skipped/>
159
+ </testcase>
149
160
  </testsuite>
150
161
  EOF
151
162
  end
@@ -164,7 +175,7 @@ describe JUnitFormatter do
164
175
 
165
176
  output.string.should == <<-EOF
166
177
  <?xml version="1.0" encoding="utf-8" ?>
167
- <testsuite errors="0" failures="1" tests="2" time="0.1" timestamp="#{@now.iso8601}">
178
+ <testsuite errors="0" failures="1" skipped="0" tests="2" time="0.1" timestamp="#{@now.iso8601}">
168
179
  <properties />
169
180
  <testcase classname="lib/&gt;foobar-s.rb" name="foobar-success &gt;&gt;&gt; &amp;&quot;&amp; &lt;&lt;&lt;" time="0.1" />
170
181
  </testsuite>
@@ -68,7 +68,7 @@ describe TapFormatter do
68
68
 
69
69
  describe "example_pending" do
70
70
 
71
- it "should do the same as example_failed" do
71
+ it "should do the same as example_failed with TODO comment" do
72
72
  example = mock("example")
73
73
  example.should_receive(:metadata).and_return({:full_description => "foobar"})
74
74
 
@@ -77,7 +77,7 @@ describe TapFormatter do
77
77
  f.example_pending(example)
78
78
 
79
79
  f.total.should eql(1)
80
- output.string.should == "not ok 1 - foobar\n"
80
+ output.string.should == "not ok 1 - # TODO foobar\n"
81
81
  end
82
82
 
83
83
  end
@@ -100,7 +100,7 @@ describe TapFormatter do
100
100
  output.string.should == <<-EOF
101
101
  ok 1 - foobar
102
102
  not ok 2 - foobar
103
- not ok 3 - foobar
103
+ not ok 3 - # TODO foobar
104
104
  1..3
105
105
  EOF
106
106
  end
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-extra-formatters
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 3
4
5
  prerelease:
5
- version: "0.3"
6
+ segments:
7
+ - 0
8
+ - 4
9
+ version: "0.4"
6
10
  platform: ruby
7
11
  authors:
8
12
  - Diego Souza
@@ -11,8 +15,7 @@ autorequire:
11
15
  bindir: bin
12
16
  cert_chain: []
13
17
 
14
- date: 2011-05-26 00:00:00 -03:00
15
- default_executable:
18
+ date: 2012-04-24 00:00:00 Z
16
19
  dependencies:
17
20
  - !ruby/object:Gem::Dependency
18
21
  name: rspec
@@ -22,6 +25,9 @@ dependencies:
22
25
  requirements:
23
26
  - - ">="
24
27
  - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
25
31
  version: "0"
26
32
  type: :development
27
33
  version_requirements: *id001
@@ -36,16 +42,15 @@ extra_rdoc_files:
36
42
  - README.rst
37
43
  files:
38
44
  - lib/tap_formatter.rb
39
- - lib/rspec-extra-formatters/junit_formatter.rb
45
+ - lib/rspec-extra-formatters.rb
40
46
  - lib/rspec-extra-formatters/tap_formatter.rb
47
+ - lib/rspec-extra-formatters/junit_formatter.rb
41
48
  - lib/j_unit_formatter.rb
42
- - lib/rspec-extra-formatters.rb
49
+ - LICENSE
50
+ - README.rst
43
51
  - spec/rspec-extra-formatters/tap_formatter_spec.rb
44
52
  - spec/rspec-extra-formatters/junit_formatter_spec.rb
45
53
  - spec/spec_helper.rb
46
- - LICENSE
47
- - README.rst
48
- has_rdoc: true
49
54
  homepage: http://dsouza.bitforest.org/2011/01/22/rspec-tap-and-junit-formatters/
50
55
  licenses: []
51
56
 
@@ -59,17 +64,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
64
  requirements:
60
65
  - - ">="
61
66
  - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
62
70
  version: "0"
63
71
  required_rubygems_version: !ruby/object:Gem::Requirement
64
72
  none: false
65
73
  requirements:
66
74
  - - ">="
67
75
  - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
68
79
  version: "0"
69
80
  requirements: []
70
81
 
71
82
  rubyforge_project:
72
- rubygems_version: 1.5.0
83
+ rubygems_version: 1.8.6
73
84
  signing_key:
74
85
  specification_version: 3
75
86
  summary: TAP and JUnit formatters for rspec