ci_reporter 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.3.2
2
+
3
+ - Fix bug trying to modify frozen environment strings
4
+ - Upgrade all specs to RSpec 1.0 style
5
+ - Add specs for rake tasks
6
+
1
7
  == 1.3.1
2
8
 
3
9
  - Fixed to be compatible with RSpec 1.0.x (added fourth parameter to Formatter#dump_summary)
data/Manifest.txt CHANGED
@@ -13,6 +13,7 @@ lib/ci/reporter/rspec.rb
13
13
  lib/ci/reporter/test_suite.rb
14
14
  lib/ci/reporter/test_unit.rb
15
15
  spec/ci/reporter/output_capture_spec.rb
16
+ spec/ci/reporter/rake/rake_tasks_spec.rb
16
17
  spec/ci/reporter/report_manager_spec.rb
17
18
  spec/ci/reporter/rspec_spec.rb
18
19
  spec/ci/reporter/test_suite_spec.rb
data/Rakefile CHANGED
@@ -1,20 +1,26 @@
1
1
  require 'spec/rake/spectask'
2
- require 'hoe'
3
2
 
4
3
  MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "LICENSE.txt", "Rakefile",
5
4
  "lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
6
5
 
7
- Hoe.new("ci_reporter", "1.3.1") do |p|
8
- p.rubyforge_name = "caldersphere"
9
- p.url = "http://caldersphere.rubyforge.org/ci_reporter"
10
- p.author = "Nick Sieger"
11
- p.email = "nick@nicksieger.com"
12
- p.summary = "CI::Reporter allows you to generate reams of XML for use with continuous integration systems."
13
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
14
- p.description = p.paragraphs_of('README.txt', 0...1).join("\n\n")
15
- p.extra_deps.reject!{|d| d.first == "hoe"}
16
- p.test_globs = ["spec/**/*_spec.rb"]
17
- end.spec.files = MANIFEST
6
+ begin
7
+ require 'hoe'
8
+ hoe = Hoe.new("ci_reporter", "1.3.2") do |p|
9
+ p.rubyforge_name = "caldersphere"
10
+ p.url = "http://caldersphere.rubyforge.org/ci_reporter"
11
+ p.author = "Nick Sieger"
12
+ p.email = "nick@nicksieger.com"
13
+ p.summary = "CI::Reporter allows you to generate reams of XML for use with continuous integration systems."
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ p.description = p.paragraphs_of('README.txt', 0...1).join("\n\n")
16
+ p.extra_deps.reject!{|d| d.first == "hoe"}
17
+ p.test_globs = ["spec/**/*_spec.rb"]
18
+ end
19
+ hoe.spec.files = MANIFEST
20
+ hoe.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
21
+ rescue LoadError
22
+ puts "You really need Hoe installed to be able to package this gem"
23
+ end
18
24
 
19
25
  # Hoe insists on setting task :default => :test
20
26
  # !@#$ no easy way to empty the default list of prerequisites
@@ -7,7 +7,7 @@ namespace :ci do
7
7
  task :rspec do
8
8
  rm_rf ENV["CI_REPORTS"] || "spec/reports"
9
9
  ENV["RSPECOPTS"] ||= ""
10
- ENV["RSPECOPTS"] << [" --require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
10
+ ENV["RSPECOPTS"] += [" --require", "#{File.dirname(__FILE__)}/rspec_loader.rb",
11
11
  "--format", "CI::Reporter::RSpec"].join(" ")
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ namespace :ci do
7
7
  task :testunit do
8
8
  rm_rf ENV["CI_REPORTS"] || "test/reports"
9
9
  ENV["TESTOPTS"] ||= ""
10
- ENV["TESTOPTS"] << " #{File.dirname(__FILE__)}/test_unit_loader.rb"
10
+ ENV["TESTOPTS"] += " #{File.dirname(__FILE__)}/test_unit_loader.rb"
11
11
  end
12
12
  end
13
13
  end
@@ -106,7 +106,7 @@ module CI
106
106
  super
107
107
  end
108
108
 
109
- def dump_summary(duration, example_count, failure_count, not_implemented_count = nil)
109
+ def dump_summary(duration, example_count, failure_count, not_implemented_count = 0)
110
110
  begin
111
111
  super
112
112
  rescue ArgumentError
@@ -5,12 +5,12 @@
5
5
  require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
6
  require 'rexml/document'
7
7
 
8
- context "Output capture" do
9
- setup do
8
+ describe "Output capture" do
9
+ before(:each) do
10
10
  @suite = CI::Reporter::TestSuite.new "test"
11
11
  end
12
12
 
13
- specify "should save stdout and stderr messages written during the test run" do
13
+ it "should save stdout and stderr messages written during the test run" do
14
14
  @suite.start
15
15
  puts "Hello"
16
16
  $stderr.print "Hi"
@@ -19,7 +19,7 @@ context "Output capture" do
19
19
  @suite.stderr.should == "Hi"
20
20
  end
21
21
 
22
- specify "should include system-out and system-err elements in the xml output" do
22
+ it "should include system-out and system-err elements in the xml output" do
23
23
  @suite.start
24
24
  puts "Hello"
25
25
  $stderr.print "Hi"
@@ -32,7 +32,7 @@ context "Output capture" do
32
32
  root.elements.to_a('//system-err').first.cdatas.first.to_s.should == "Hi"
33
33
  end
34
34
 
35
- specify "should return $stdout and $stderr to original value after finish" do
35
+ it "should return $stdout and $stderr to original value after finish" do
36
36
  out, err = $stdout, $stderr
37
37
  @suite.start
38
38
  $stdout.object_id.should_not == out.object_id
@@ -42,7 +42,7 @@ context "Output capture" do
42
42
  $stderr.object_id.should == err.object_id
43
43
  end
44
44
 
45
- specify "should capture only during run of owner test suite" do
45
+ it "should capture only during run of owner test suite" do
46
46
  $stdout.print "A"
47
47
  $stderr.print "A"
48
48
  @suite.start
@@ -0,0 +1,68 @@
1
+ # (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ require File.dirname(__FILE__) + "/../../../spec_helper.rb"
6
+ require 'rake'
7
+
8
+ def save_env(v)
9
+ ENV["PREV_#{v}"] = ENV[v]
10
+ end
11
+ def restore_env(v)
12
+ ENV[v] = ENV["PREV_#{v}"]
13
+ ENV.delete("PREV_#{v}")
14
+ end
15
+
16
+ describe "ci_reporter ci:setup:testunit task" do
17
+ before(:each) do
18
+ @rake = Rake::Application.new
19
+ Rake.application = @rake
20
+ load CI_REPORTER_LIB + '/ci/reporter/rake/test_unit.rb'
21
+ save_env "CI_REPORTS"
22
+ save_env "TESTOPTS"
23
+ ENV["CI_REPORTS"] = "some-bogus-nonexistent-directory-that-wont-fail-rm_rf"
24
+ end
25
+ after(:each) do
26
+ restore_env "TESTOPTS"
27
+ restore_env "CI_REPORTS"
28
+ Rake.application = nil
29
+ end
30
+
31
+ it "should set ENV['TESTOPTS'] to include test/unit setup file" do
32
+ @rake["ci:setup:testunit"].invoke
33
+ ENV["TESTOPTS"].should =~ /test_unit_loader/
34
+ end
35
+
36
+ it "should append to ENV['TESTOPTS'] if it already contains a value" do
37
+ ENV["TESTOPTS"] = "somevalue".freeze
38
+ @rake["ci:setup:testunit"].invoke
39
+ ENV["TESTOPTS"].should =~ /somevalue.*test_unit_loader/
40
+ end
41
+ end
42
+
43
+ describe "ci_reporter ci:setup:rspec task" do
44
+ before(:each) do
45
+ @rake = Rake::Application.new
46
+ Rake.application = @rake
47
+ load CI_REPORTER_LIB + '/ci/reporter/rake/rspec.rb'
48
+ save_env "CI_REPORTS"
49
+ save_env "RSPECOPTS"
50
+ ENV["CI_REPORTS"] = "some-bogus-nonexistent-directory-that-wont-fail-rm_rf"
51
+ end
52
+ after(:each) do
53
+ restore_env "RSPECOPTS"
54
+ restore_env "CI_REPORTS"
55
+ Rake.application = nil
56
+ end
57
+
58
+ it "should set ENV['RSPECOPTS'] to include rspec formatter args" do
59
+ @rake["ci:setup:rspec"].invoke
60
+ ENV["RSPECOPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpec/
61
+ end
62
+
63
+ it "should append to ENV['RSPECOPTS'] if it already contains a value" do
64
+ ENV["RSPECOPTS"] = "somevalue".freeze
65
+ @rake["ci:setup:rspec"].invoke
66
+ ENV["RSPECOPTS"].should =~ /somevalue.*--require.*rspec_loader.*--format.*CI::Reporter::RSpec/
67
+ end
68
+ end
@@ -4,36 +4,36 @@
4
4
 
5
5
  require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
6
 
7
- context "The ReportManager" do
8
- setup do
7
+ describe "The ReportManager" do
8
+ before(:each) do
9
9
  @reports_dir = REPORTS_DIR
10
10
  end
11
11
 
12
- teardown do
12
+ after(:each) do
13
13
  FileUtils.rm_rf @reports_dir
14
14
  ENV["CI_REPORTS"] = nil
15
15
  end
16
16
 
17
- specify "should create the report directory according to the given prefix" do
17
+ it "should create the report directory according to the given prefix" do
18
18
  CI::Reporter::ReportManager.new("spec")
19
- File.directory?(@reports_dir).should_be true
19
+ File.directory?(@reports_dir).should be_true
20
20
  end
21
21
 
22
- specify "should create the report directory based on CI_REPORTS environment variable if set" do
22
+ it "should create the report directory based on CI_REPORTS environment variable if set" do
23
23
  @reports_dir = "#{Dir.getwd}/dummy"
24
24
  ENV["CI_REPORTS"] = @reports_dir
25
25
  CI::Reporter::ReportManager.new("spec")
26
- File.directory?(@reports_dir).should_be true
26
+ File.directory?(@reports_dir).should be_true
27
27
  end
28
28
 
29
- specify "should write reports based on name and xml content of a test suite" do
29
+ it "should write reports based on name and xml content of a test suite" do
30
30
  reporter = CI::Reporter::ReportManager.new("spec")
31
31
  suite = mock("test suite")
32
32
  suite.should_receive(:name).and_return("some test suite name")
33
33
  suite.should_receive(:to_xml).and_return("<xml></xml>")
34
34
  reporter.write_report(suite)
35
35
  filename = "#{REPORTS_DIR}/SPEC-some-test-suite-name.xml"
36
- File.exist?(filename).should_be true
36
+ File.exist?(filename).should be_true
37
37
  File.open(filename) {|f| f.read.should == "<xml></xml>"}
38
38
  end
39
39
  end
@@ -5,8 +5,8 @@
5
5
  require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
6
  require 'stringio'
7
7
 
8
- context "The RSpec reporter" do
9
- setup do
8
+ describe "The RSpec reporter" do
9
+ before(:each) do
10
10
  @error = mock("error")
11
11
  @error.stub!(:exception).and_return do
12
12
  begin
@@ -20,20 +20,20 @@ context "The RSpec reporter" do
20
20
  @fmt = CI::Reporter::RSpec.new(StringIO.new(""), false, false, @report_mgr)
21
21
  end
22
22
 
23
- specify "should create a test suite with one success and one failure" do
23
+ it "should create a test suite with one success and one failure" do
24
24
  @report_mgr.should_receive(:write_report).and_return do |suite|
25
25
  suite.testcases.length.should == 2
26
- suite.testcases.first.should_not_be_failure
27
- suite.testcases.first.should_not_be_error
28
- suite.testcases.last.should_be_error
26
+ suite.testcases.first.should_not be_failure
27
+ suite.testcases.first.should_not be_error
28
+ suite.testcases.last.should be_error
29
29
  end
30
30
 
31
31
  @fmt.start(2)
32
- @fmt.add_context("A context", true)
33
- @fmt.spec_started("should pass")
34
- @fmt.spec_passed("should pass")
35
- @fmt.spec_started("should fail")
36
- @fmt.spec_failed("should fail", 1, @error)
32
+ @fmt.add_behaviour("A context")
33
+ @fmt.example_started("should pass")
34
+ @fmt.example_passed("should pass")
35
+ @fmt.example_started("should fail")
36
+ @fmt.example_failed("should fail", 1, @error)
37
37
  @fmt.dump_summary(0.1, 2, 1)
38
38
  end
39
39
  end
@@ -5,25 +5,25 @@
5
5
  require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
6
  require 'rexml/document'
7
7
 
8
- context "A TestSuite" do
9
- setup do
8
+ describe "A TestSuite" do
9
+ before(:each) do
10
10
  @suite = CI::Reporter::TestSuite.new("example suite")
11
11
  end
12
12
 
13
- specify "should collect timings when start and finish are invoked in sequence" do
13
+ it "should collect timings when start and finish are invoked in sequence" do
14
14
  @suite.start
15
15
  @suite.finish
16
- @suite.time.should_be > 0
16
+ @suite.time.should > 0
17
17
  end
18
18
 
19
- specify "should aggregate tests" do
19
+ it "should aggregate tests" do
20
20
  @suite.start
21
21
  @suite.testcases << CI::Reporter::TestCase.new("example test")
22
22
  @suite.finish
23
23
  @suite.tests.should == 1
24
24
  end
25
25
 
26
- specify "should indicate number of failures and errors" do
26
+ it "should indicate number of failures and errors" do
27
27
  failure = mock("failure")
28
28
  failure.stub!(:failure?).and_return true
29
29
  failure.stub!(:error?).and_return false
@@ -43,11 +43,10 @@ context "A TestSuite" do
43
43
  @suite.failures.should == 1
44
44
  @suite.errors.should == 1
45
45
  end
46
-
47
46
  end
48
47
 
49
- context "TestSuite xml" do
50
- setup do
48
+ describe "TestSuite xml" do
49
+ before(:each) do
51
50
  @suite = CI::Reporter::TestSuite.new("example suite")
52
51
  @suite.assertions = 11
53
52
  begin
@@ -57,7 +56,7 @@ context "TestSuite xml" do
57
56
  end
58
57
  end
59
58
 
60
- specify "should contain Ant/JUnit-formatted description of entire suite" do
59
+ it "should contain Ant/JUnit-formatted description of entire suite" do
61
60
  failure = mock("failure")
62
61
  failure.stub!(:failure?).and_return true
63
62
  failure.stub!(:error?).and_return false
@@ -92,7 +91,7 @@ context "TestSuite xml" do
92
91
  testcases.length.should == 3
93
92
  end
94
93
 
95
- specify "should contain full exception type and message in location element" do
94
+ it "should contain full exception type and message in location element" do
96
95
  failure = mock("failure")
97
96
  failure.stub!(:failure?).and_return true
98
97
  failure.stub!(:error?).and_return false
@@ -114,7 +113,7 @@ context "TestSuite xml" do
114
113
  location.should =~ Regexp.new(failure.name)
115
114
  end
116
115
 
117
- specify "should filter attributes properly for invalid characters" do
116
+ it "should filter attributes properly for invalid characters" do
118
117
  failure = mock("failure")
119
118
  failure.stub!(:failure?).and_return true
120
119
  failure.stub!(:error?).and_return false
@@ -128,18 +127,18 @@ context "TestSuite xml" do
128
127
  @suite.finish
129
128
 
130
129
  xml = @suite.to_xml
131
- xml.should_match %r/message="There was a &lt;failure&gt;\.\.\."/
130
+ xml.should =~ %r/message="There was a &lt;failure&gt;\.\.\."/
132
131
  end
133
132
  end
134
133
 
135
- context "A TestCase" do
136
- setup do
134
+ describe "A TestCase" do
135
+ before(:each) do
137
136
  @tc = CI::Reporter::TestCase.new("example test")
138
137
  end
139
138
 
140
- specify "should collect timings when start and finish are invoked in sequence" do
139
+ it "should collect timings when start and finish are invoked in sequence" do
141
140
  @tc.start
142
141
  @tc.finish
143
- @tc.time.should_be > 0
142
+ @tc.time.should > 0
144
143
  end
145
144
  end
@@ -4,15 +4,15 @@
4
4
 
5
5
  require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
6
 
7
- context "The TestUnit reporter" do
8
- setup do
7
+ describe "The TestUnit reporter" do
8
+ before(:each) do
9
9
  @report_mgr = mock("report manager")
10
10
  @testunit = CI::Reporter::TestUnit.new(nil, @report_mgr)
11
11
  @result = mock("result")
12
12
  @result.stub!(:assertion_count).and_return(7)
13
13
  end
14
14
 
15
- specify "should build suites based on adjacent tests with the same class name" do
15
+ it "should build suites based on adjacent tests with the same class name" do
16
16
  @suite = nil
17
17
  @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
18
18
 
@@ -26,14 +26,14 @@ context "The TestUnit reporter" do
26
26
  @suite.name.should == "TestCaseClass"
27
27
  @suite.testcases.length.should == 2
28
28
  @suite.testcases.first.name.should == "test_one"
29
- @suite.testcases.first.should_not_be_failure
30
- @suite.testcases.first.should_not_be_error
29
+ @suite.testcases.first.should_not be_failure
30
+ @suite.testcases.first.should_not be_error
31
31
  @suite.testcases.last.name.should == "test_two"
32
- @suite.testcases.last.should_not_be_failure
33
- @suite.testcases.last.should_not_be_error
32
+ @suite.testcases.last.should_not be_failure
33
+ @suite.testcases.last.should_not be_error
34
34
  end
35
35
 
36
- specify "should build two suites when encountering different class names" do
36
+ it "should build two suites when encountering different class names" do
37
37
  @suites = []
38
38
  @report_mgr.should_receive(:write_report).twice.and_return {|suite| @suites << suite }
39
39
 
@@ -52,7 +52,7 @@ context "The TestUnit reporter" do
52
52
  @suites.last.testcases.first.name.should == "test_two"
53
53
  end
54
54
 
55
- specify "should record assertion counts during test run" do
55
+ it "should record assertion counts during test run" do
56
56
  @suite = nil
57
57
  @report_mgr.should_receive(:write_report).and_return {|suite| @suite = suite }
58
58
 
@@ -64,7 +64,7 @@ context "The TestUnit reporter" do
64
64
  @suite.assertions.should == 7
65
65
  end
66
66
 
67
- specify "should add failures to testcases when encountering a fault" do
67
+ it "should add failures to testcases when encountering a fault" do
68
68
  begin
69
69
  raise StandardError, "error"
70
70
  rescue => e
@@ -84,10 +84,10 @@ context "The TestUnit reporter" do
84
84
  @suite.name.should == "TestCaseClass"
85
85
  @suite.testcases.length.should == 2
86
86
  @suite.testcases.first.name.should == "test_one"
87
- @suite.testcases.first.should_not_be_failure
88
- @suite.testcases.first.should_not_be_error
87
+ @suite.testcases.first.should_not be_failure
88
+ @suite.testcases.first.should_not be_error
89
89
  @suite.testcases.last.name.should == "test_two"
90
- @suite.testcases.last.should_not_be_failure
91
- @suite.testcases.last.should_be_error
90
+ @suite.testcases.last.should_not be_failure
91
+ @suite.testcases.last.should be_error
92
92
  end
93
93
  end
data/spec/spec_helper.rb CHANGED
@@ -5,9 +5,14 @@
5
5
  require 'rubygems'
6
6
  gem 'rspec'
7
7
  require 'spec'
8
- $: << File.dirname(__FILE__) + "/../lib"
8
+
9
+ unless defined?(CI_REPORTER_LIB)
10
+ CI_REPORTER_LIB = File.expand_path(File.dirname(__FILE__) + "/../lib")
11
+ $: << CI_REPORTER_LIB
12
+ end
13
+
9
14
  require 'ci/reporter/core'
10
15
  require 'ci/reporter/test_unit'
11
16
  require 'ci/reporter/rspec'
12
17
 
13
- REPORTS_DIR = File.dirname(__FILE__) + "/reports"
18
+ REPORTS_DIR = File.dirname(__FILE__) + "/reports" unless defined?(REPORTS_DIR)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ci_reporter
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.3.1
7
- date: 2007-05-30 00:00:00 -05:00
6
+ version: 1.3.2
7
+ date: 2007-06-06 00:00:00 -07:00
8
8
  summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.
9
9
  require_paths:
10
10
  - lib
@@ -44,6 +44,7 @@ files:
44
44
  - lib/ci/reporter/test_suite.rb
45
45
  - lib/ci/reporter/test_unit.rb
46
46
  - spec/ci/reporter/output_capture_spec.rb
47
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
47
48
  - spec/ci/reporter/report_manager_spec.rb
48
49
  - spec/ci/reporter/rspec_spec.rb
49
50
  - spec/ci/reporter/test_suite_spec.rb
@@ -52,14 +53,19 @@ files:
52
53
  - tasks/ci_reporter.rake
53
54
  test_files:
54
55
  - spec/ci/reporter/output_capture_spec.rb
56
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
55
57
  - spec/ci/reporter/report_manager_spec.rb
56
58
  - spec/ci/reporter/rspec_spec.rb
57
59
  - spec/ci/reporter/test_suite_spec.rb
58
60
  - spec/ci/reporter/test_unit_spec.rb
59
- rdoc_options: []
60
-
61
- extra_rdoc_files: []
62
-
61
+ rdoc_options:
62
+ - --main
63
+ - README.txt
64
+ extra_rdoc_files:
65
+ - History.txt
66
+ - Manifest.txt
67
+ - README.txt
68
+ - LICENSE.txt
63
69
  executables: []
64
70
 
65
71
  extensions: []