ci_reporter_rspec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c5782dda8a0c0bda589fb30fb0dff6af461a3b6c
4
+ data.tar.gz: 50004c58bab2655617aec6e18a2bfc7eced4ec5a
5
+ SHA512:
6
+ metadata.gz: 7f1550786b9be743b0bbf452204001eb2f7a424129d4916439ebf8654b044c0ea94d972c07ef36c79d625ba853617fbfe9aef4ba158b9dd828e4a20fdab0b36a
7
+ data.tar.gz: b813f2e977a9c41d546784207090330f0ca74dbb795b74c7afcf888e0b378c17469eea16a5a5f79b2788cf73aac48515b8cfda775e47d1795bf0260e65ed9328
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0
4
+ - 2.1
5
+ - jruby
6
+
7
+ gemfile:
8
+ - Gemfile
9
+ - gemfiles/Gemfile.2.14
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ci_reporter_rspec.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2006-2014 Nick Sieger <nicksieger@gmail.com>
2
+ Copyright (c) 2014 The CI Reporter authors
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,75 @@
1
+ # CI::Reporter::RSpec
2
+
3
+ Connects [RSpec][rspec] to [CI::Reporter][ci], and then to your CI
4
+ system.
5
+
6
+ [rspec]: https://www.relishapp.com/rspec
7
+ [ci]: https://github.com/ci-reporter/ci_reporter
8
+
9
+ ## Supported versions
10
+
11
+ The latest release of RSpec 2.14 and 2.99 are supported. RSpec 3 is
12
+ not yet supported.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'ci_reporter_rspec'
20
+ ```
21
+
22
+ And then install it:
23
+
24
+ ```
25
+ $ bundle
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ Require the reporter in your Rakefile, and ensure that
31
+ `ci:setup:rspec` is a dependency of your RSpec task:
32
+
33
+ ```ruby
34
+ require 'ci/reporter/rake/rspec'
35
+
36
+ # ...
37
+ # Rake code that creates a task called `:rspec`
38
+ # ...
39
+
40
+ task :rspec => 'ci:setup:rspec'
41
+ ```
42
+
43
+ ### Advanced usage
44
+
45
+ Refer to the shared [documentation][ci] for details on setting up
46
+ CI::Reporter.
47
+
48
+ ### `rspec-rails`
49
+
50
+ If you use the [rspec-rails][rspec-rails] gem, you can follow the
51
+ example above and use the predefined Rake target `:spec`.
52
+
53
+ [rspec-rails]: https://www.relishapp.com/rspec/rspec-rails/docs
54
+
55
+ ## Formatters
56
+
57
+ CI::Reporter has separate Rake tasks for each built-in RSpec
58
+ formatter. Depending upon which formatter you would like, call the
59
+ corresponding task.
60
+
61
+ | Formatter | Task |
62
+ |--------------------|--------------------|
63
+ | Progress (default) | ci:setup:rspec |
64
+ | Base | ci:setup:rspecbase |
65
+ | Documentation | ci:setup:rspecdoc |
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/ci-reporter/ci_reporter_rspec/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Add a failing test.
72
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 5. Ensure tests pass.
74
+ 6. Push to the branch (`git push origin my-new-feature`)
75
+ 7. Create a new Pull Request
@@ -0,0 +1,32 @@
1
+ require "bundler/gem_tasks"
2
+ require 'ci/reporter/internal'
3
+ include CI::Reporter::Internal
4
+
5
+ namespace :generate do
6
+ task :clean do
7
+ rm_rf "acceptance/reports"
8
+ end
9
+
10
+ task :rspec do
11
+ rspec = "#{Gem.loaded_specs['rspec-core'].gem_dir}/exe/rspec"
12
+ run_ruby_acceptance "-S #{rspec} --require ci/reporter/rake/rspec_loader --format CI::Reporter::RSpec acceptance/rspec_example_spec.rb"
13
+ end
14
+
15
+ task :all => [:clean, :rspec]
16
+ end
17
+
18
+ task :acceptance => "generate:all"
19
+
20
+ require 'rspec/core/rake_task'
21
+ RSpec::Core::RakeTask.new(:acceptance_spec) do |t|
22
+ t.pattern = FileList['acceptance/verification_spec.rb']
23
+ t.rspec_opts = "--color"
24
+ end
25
+ task :acceptance => :acceptance_spec
26
+
27
+ RSpec::Core::RakeTask.new(:unit_spec) do |t|
28
+ t.pattern = FileList['spec']
29
+ t.rspec_opts = "--color"
30
+ end
31
+
32
+ task :default => [:unit_spec, :acceptance]
@@ -0,0 +1 @@
1
+ reports/
@@ -0,0 +1,18 @@
1
+ describe "RSpec example" do
2
+ it "should succeed" do
3
+ true.should be true
4
+ nil.should be_nil
5
+ end
6
+
7
+ it "should fail" do
8
+ true.should be false
9
+ end
10
+
11
+ it "should be pending"
12
+
13
+ describe "nested" do
14
+ it "should succeed" do
15
+ true.should be true
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ require 'rexml/document'
2
+
3
+ REPORTS_DIR = File.dirname(__FILE__) + '/reports'
4
+
5
+ describe "RSpec acceptance" do
6
+ it "should generate two XML files" do
7
+ File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')).should == true
8
+ File.exist?(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')).should == true
9
+ end
10
+
11
+ it "should have two tests and one failure" do
12
+ doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example.xml')) do |f|
13
+ REXML::Document.new(f)
14
+ end
15
+ doc.root.attributes["errors"].should == "0"
16
+ doc.root.attributes["failures"].should == "1"
17
+ doc.root.attributes["tests"].should == "3"
18
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 3
19
+ failures = doc.root.elements.to_a("/testsuite/testcase/failure")
20
+ failures.size.should == 1
21
+ failures.first.attributes["type"].should =~ /ExpectationNotMetError/
22
+ end
23
+
24
+ it "should have one test in the nested example report" do
25
+ doc = File.open(File.join(REPORTS_DIR, 'SPEC-RSpec-example-nested.xml')) do |f|
26
+ REXML::Document.new(f)
27
+ end
28
+ doc.root.attributes["errors"].should == "0"
29
+ doc.root.attributes["failures"].should == "0"
30
+ doc.root.attributes["tests"].should == "1"
31
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 1
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ci/reporter/rspec/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ci_reporter_rspec"
8
+ spec.version = CI::Reporter::RSpec::VERSION
9
+ spec.authors = ["Nick Sieger", "Jake Goulding"]
10
+ spec.email = ["nick@nicksieger.com", "jake.goulding@gmail.com"]
11
+ spec.summary = %q{Connects CI::Reporter to RSpec}
12
+ spec.homepage = "https://github.com/ci-reporter/ci_reporter_rspec"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|acceptance)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "rspec", "~> 2.14"
21
+ spec.add_dependency "ci_reporter", "2.0.0.alpha1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1 @@
1
+ Gemfile*lock
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'rspec', '~> 2.14.0'
5
+ gem 'ci_reporter_rspec', path: '..'
@@ -0,0 +1,27 @@
1
+ require 'ci/reporter/rake/utils'
2
+
3
+ namespace :ci do
4
+ namespace :setup do
5
+ task :spec_report_cleanup do
6
+ rm_rf ENV["CI_REPORTS"] || "spec/reports"
7
+ end
8
+
9
+ task :rspec => :spec_report_cleanup do
10
+ spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"),
11
+ "--format", "CI::Reporter::RSpec"].join(" ")
12
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
13
+ end
14
+
15
+ task :rspecdoc => :spec_report_cleanup do
16
+ spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"),
17
+ "--format", "CI::Reporter::RSpecDoc"].join(" ")
18
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
19
+ end
20
+
21
+ task :rspecbase => :spec_report_cleanup do
22
+ spec_opts = ["--require", CI::Reporter.maybe_quote_filename("#{File.dirname(__FILE__)}/rspec_loader.rb"),
23
+ "--format", "CI::Reporter::RSpecBase"].join(" ")
24
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} #{spec_opts}"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,2 @@
1
+ $: << File.dirname(__FILE__) + "/../../.."
2
+ require 'ci/reporter/rspec'
@@ -0,0 +1,173 @@
1
+ require 'ci/reporter/core'
2
+
3
+ module CI
4
+ module Reporter
5
+ module RSpecFormatters
6
+ require 'rspec/core/formatters/base_formatter'
7
+ require 'rspec/core/formatters/progress_formatter'
8
+ require 'rspec/core/formatters/documentation_formatter'
9
+ BaseFormatter = ::RSpec::Core::Formatters::BaseFormatter
10
+ ProgressFormatter = ::RSpec::Core::Formatters::ProgressFormatter
11
+ DocFormatter = ::RSpec::Core::Formatters::DocumentationFormatter
12
+ # See https://github.com/nicksieger/ci_reporter/issues/76 and
13
+ # https://github.com/nicksieger/ci_reporter/issues/80
14
+ require 'rspec/core/version'
15
+ RSpec_2_12_0_bug = (::RSpec::Core::Version::STRING == '2.12.0' &&
16
+ !BaseFormatter.instance_methods(false).map(&:to_s).include?("format_backtrace"))
17
+ end
18
+
19
+ # Wrapper around a <code>RSpec</code> error or failure to be used by the test suite to interpret results.
20
+ class RSpec2Failure
21
+ attr_reader :exception
22
+
23
+ def initialize(example, formatter)
24
+ @formatter = formatter
25
+ @example = example
26
+ if @example.respond_to?(:execution_result)
27
+ @exception = @example.execution_result[:exception] || @example.execution_result[:exception_encountered]
28
+ else
29
+ @exception = @example.metadata[:execution_result][:exception]
30
+ end
31
+ end
32
+
33
+ def name
34
+ @exception.class.name
35
+ end
36
+
37
+ def message
38
+ @exception.message
39
+ end
40
+
41
+ def failure?
42
+ exception.is_a?(::RSpec::Expectations::ExpectationNotMetError)
43
+ end
44
+
45
+ def error?
46
+ !failure?
47
+ end
48
+
49
+ def location
50
+ output = []
51
+ output.push "#{exception.class.name << ":"}" unless exception.class.name =~ /RSpec/
52
+ output.push @exception.message
53
+
54
+ format_metadata = RSpecFormatters::RSpec_2_12_0_bug ? @example.metadata : @example
55
+
56
+ [@formatter.format_backtrace(@exception.backtrace, format_metadata)].flatten.each do |backtrace_info|
57
+ backtrace_info.lines.each do |line|
58
+ output.push " #{line}"
59
+ end
60
+ end
61
+ output.join "\n"
62
+ end
63
+ end
64
+
65
+ # Custom +RSpec+ formatter used to hook into the spec runs and capture results.
66
+ class RSpec
67
+ attr_accessor :report_manager
68
+ attr_accessor :formatter
69
+ def initialize(*args)
70
+ @formatter ||= RSpecFormatters::ProgressFormatter.new(*args)
71
+ @report_manager = ReportManager.new("spec")
72
+ @suite = nil
73
+ end
74
+
75
+ def example_group_started(example_group)
76
+ @formatter.example_group_started(example_group)
77
+ new_suite(description_for(example_group))
78
+ end
79
+
80
+ def example_started(name_or_example)
81
+ @formatter.example_started(name_or_example)
82
+ spec = TestCase.new
83
+ @suite.testcases << spec
84
+ spec.start
85
+ end
86
+
87
+ def example_failed(name_or_example, *rest)
88
+ @formatter.example_failed(name_or_example, *rest)
89
+
90
+ # In case we fail in before(:all)
91
+ example_started(name_or_example) if @suite.testcases.empty?
92
+
93
+ failure = RSpec2Failure.new(name_or_example, @formatter)
94
+
95
+ spec = @suite.testcases.last
96
+ spec.finish
97
+ spec.name = description_for(name_or_example)
98
+ spec.failures << failure
99
+ end
100
+
101
+ def example_passed(name_or_example)
102
+ @formatter.example_passed(name_or_example)
103
+ spec = @suite.testcases.last
104
+ spec.finish
105
+ spec.name = description_for(name_or_example)
106
+ end
107
+
108
+ def example_pending(*args)
109
+ @formatter.example_pending(*args)
110
+ name = description_for(args[0])
111
+ spec = @suite.testcases.last
112
+ spec.finish
113
+ spec.name = "#{name} (PENDING)"
114
+ spec.skipped = true
115
+ end
116
+
117
+ def dump_summary(*args)
118
+ @formatter.dump_summary(*args)
119
+ write_report
120
+ @formatter.dump_failures
121
+ end
122
+
123
+ def respond_to?(*args)
124
+ @formatter.respond_to?(*args)
125
+ end
126
+
127
+ # Pass through other methods to RSpec formatter for compatibility
128
+ def method_missing(meth,*args,&block)
129
+ @formatter.send(meth,*args,&block)
130
+ end
131
+
132
+ private
133
+ def description_for(name_or_example)
134
+ if name_or_example.respond_to?(:full_description)
135
+ name_or_example.full_description
136
+ elsif name_or_example.respond_to?(:metadata)
137
+ name_or_example.metadata[:example_group][:full_description]
138
+ elsif name_or_example.respond_to?(:description)
139
+ name_or_example.description
140
+ else
141
+ "UNKNOWN"
142
+ end
143
+ end
144
+
145
+ def write_report
146
+ if @suite
147
+ @suite.finish
148
+ @report_manager.write_report(@suite)
149
+ end
150
+ end
151
+
152
+ def new_suite(name)
153
+ write_report if @suite
154
+ @suite = TestSuite.new name
155
+ @suite.start
156
+ end
157
+ end
158
+
159
+ class RSpecDoc < RSpec
160
+ def initialize(*args)
161
+ @formatter = RSpecFormatters::DocFormatter.new(*args)
162
+ super
163
+ end
164
+ end
165
+
166
+ class RSpecBase < RSpec
167
+ def initialize(*args)
168
+ @formatter = RSpecFormatters::BaseFormatter.new(*args)
169
+ super
170
+ end
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,7 @@
1
+ module CI
2
+ module Reporter
3
+ class RSpec
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + "/../../../spec_helper.rb"
2
+ require 'rake'
3
+
4
+ require 'ci/reporter/internal'
5
+ include CI::Reporter::Internal
6
+
7
+ describe "ci_reporter ci:setup:rspec task" do
8
+ before(:each) do
9
+ @rake = Rake::Application.new
10
+ Rake.application = @rake
11
+ load CI_REPORTER_LIB + '/ci/reporter/rake/rspec.rb'
12
+ save_env "CI_REPORTS"
13
+ save_env "SPEC_OPTS"
14
+ ENV["CI_REPORTS"] = "some-bogus-nonexistent-directory-that-wont-fail-rm_rf"
15
+ end
16
+ after(:each) do
17
+ restore_env "SPEC_OPTS"
18
+ restore_env "CI_REPORTS"
19
+ Rake.application = nil
20
+ end
21
+
22
+ it "should set ENV['SPEC_OPTS'] to include rspec formatter args" do
23
+ @rake["ci:setup:rspec"].invoke
24
+ ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpec/
25
+ end
26
+
27
+ it "should set ENV['SPEC_OPTS'] to include rspec doc formatter if task is ci:setup:rspecdoc" do
28
+ @rake["ci:setup:rspecdoc"].invoke
29
+ ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpecDoc/
30
+ end
31
+
32
+ it "should set ENV['SPEC_OPTS'] to include rspec base formatter if task is ci:setup:rspecbase" do
33
+ @rake["ci:setup:rspecbase"].invoke
34
+ ENV["SPEC_OPTS"].should =~ /--require.*rspec_loader.*--format.*CI::Reporter::RSpecBase/
35
+ end
36
+
37
+ it "should append to ENV['SPEC_OPTS'] if it already contains a value" do
38
+ ENV["SPEC_OPTS"] = "somevalue".freeze
39
+ @rake["ci:setup:rspec"].invoke
40
+ ENV["SPEC_OPTS"].should =~ /somevalue.*--require.*rspec_loader.*--format.*CI::Reporter::RSpec/
41
+ end
42
+ end
@@ -0,0 +1,148 @@
1
+ require File.dirname(__FILE__) + "/../../spec_helper.rb"
2
+ require 'ci/reporter/rspec'
3
+ require 'stringio'
4
+
5
+ describe "The RSpec reporter" do
6
+ before(:each) do
7
+ @error = double("error")
8
+ @error.stub(:expectation_not_met?).and_return(false)
9
+ @error.stub(:pending_fixed?).and_return(false)
10
+ @error.stub(:exception).and_return(StandardError.new)
11
+ @report_mgr = double("report manager")
12
+ @options = double("options")
13
+ @args = [@options, StringIO.new("")]
14
+ @args.shift unless defined?(::Spec) && ::Spec::VERSION::MAJOR == 1 && ::Spec::VERSION::MINOR >= 1
15
+ @fmt = CI::Reporter::RSpec.new *@args
16
+ @fmt.report_manager = @report_mgr
17
+ @formatter = double("formatter")
18
+ @fmt.formatter = @formatter
19
+ end
20
+
21
+ it "should use a progress bar formatter by default" do
22
+ fmt = CI::Reporter::RSpec.new *@args
23
+ fmt.formatter.should be_instance_of(CI::Reporter::RSpecFormatters::ProgressFormatter)
24
+ end
25
+
26
+ it "should use a specdoc formatter for RSpecDoc" do
27
+ fmt = CI::Reporter::RSpecDoc.new *@args
28
+ fmt.formatter.should be_instance_of(CI::Reporter::RSpecFormatters::DocFormatter)
29
+ end
30
+
31
+ def rspec2_failing_example(exception_text)
32
+ double('RSpec2.2 Example',
33
+ :execution_result => {
34
+ :exception => StandardError.new(exception_text)
35
+ },
36
+ :metadata => {
37
+ :example_group => {
38
+ :full_description => "description"
39
+ }
40
+ })
41
+ end
42
+
43
+ it "should create a test suite with one success, one failure, and one pending" do
44
+ @report_mgr.should_receive(:write_report) do |suite|
45
+ suite.testcases.length.should == 3
46
+ suite.testcases[0].should_not be_failure
47
+ suite.testcases[0].should_not be_error
48
+ suite.testcases[1].should be_error
49
+ suite.testcases[2].name.should =~ /\(PENDING\)/
50
+ end
51
+
52
+ example_group = double "example group"
53
+ example_group.stub(:description).and_return "A context"
54
+
55
+ @formatter.should_receive(:start).with(3)
56
+ @formatter.should_receive(:example_group_started).with(example_group)
57
+ @formatter.should_receive(:example_started).exactly(3).times
58
+ @formatter.should_receive(:example_passed).once
59
+ @formatter.should_receive(:example_failed).once
60
+ @formatter.should_receive(:example_pending).once
61
+ @formatter.should_receive(:start_dump).once
62
+ @formatter.should_receive(:dump_failure).once
63
+ @formatter.should_receive(:dump_summary).once
64
+ @formatter.should_receive(:dump_pending).once
65
+ @formatter.should_receive(:dump_failures).once
66
+ @formatter.should_receive(:close).once
67
+
68
+ @fmt.start(3)
69
+ @fmt.example_group_started(example_group)
70
+ @fmt.example_started("should pass")
71
+ @fmt.example_passed("should pass")
72
+ @fmt.example_started("should fail")
73
+ @fmt.example_failed(rspec2_failing_example("should fail"), 1, @error)
74
+ @fmt.example_started("should be pending")
75
+ @fmt.example_pending("A context", "should be pending", "Not Yet Implemented")
76
+ @fmt.start_dump
77
+ @fmt.dump_failure(1, double("failure"))
78
+ @fmt.dump_summary(0.1, 3, 1, 1)
79
+ @fmt.dump_pending
80
+ @fmt.close
81
+ end
82
+
83
+ it "should use the example #description method when available" do
84
+ group = double "example group"
85
+ group.stub(:description).and_return "group description"
86
+ example = double "example"
87
+ example.stub(:description).and_return "should do something"
88
+
89
+ @formatter.should_receive(:start)
90
+ @formatter.should_receive(:example_group_started).with(group)
91
+ @formatter.should_receive(:example_started).with(example).once
92
+ @formatter.should_receive(:example_passed).once
93
+ @formatter.should_receive(:dump_summary)
94
+ @formatter.should_receive(:dump_failures).once
95
+ @report_mgr.should_receive(:write_report) do |suite|
96
+ suite.testcases.last.name.should == "should do something"
97
+ end
98
+
99
+ @fmt.start(2)
100
+ @fmt.example_group_started(group)
101
+ @fmt.example_started(example)
102
+ @fmt.example_passed(example)
103
+ @fmt.dump_summary(0.1, 1, 0, 0)
104
+ end
105
+
106
+ it "should create a test suite with failure in before(:all)" do
107
+ example_group = double "example group"
108
+ example_group.stub(:description).and_return "A context"
109
+
110
+ @formatter.should_receive(:start)
111
+ @formatter.should_receive(:example_group_started).with(example_group)
112
+ @formatter.should_receive(:example_started).once
113
+ @formatter.should_receive(:example_failed).once
114
+ @formatter.should_receive(:dump_summary)
115
+ @formatter.should_receive(:dump_failures).once
116
+ @report_mgr.should_receive(:write_report)
117
+
118
+ @fmt.start(2)
119
+ @fmt.example_group_started(example_group)
120
+ @fmt.example_failed(rspec2_failing_example("should fail"), 1, @error)
121
+ @fmt.dump_summary(0.1, 1, 0, 0)
122
+ end
123
+
124
+ describe 'RSpec2Failure' do
125
+ before(:each) do
126
+ @formatter = double "formatter"
127
+ @formatter.should_receive(:format_backtrace).and_return("backtrace")
128
+ @rspec20_example = double('RSpec2.0 Example',
129
+ :execution_result => {:exception_encountered => StandardError.new('rspec2.0 ftw')},
130
+ :metadata => {})
131
+
132
+ @rspec22_example = rspec2_failing_example('rspec2.2 ftw')
133
+ end
134
+
135
+ it 'should handle rspec (< 2.2) execution results' do
136
+ failure = CI::Reporter::RSpec2Failure.new(@rspec20_example, @formatter)
137
+ failure.name.should_not be_nil
138
+ failure.message.should == 'rspec2.0 ftw'
139
+ failure.location.should_not be_nil
140
+ end
141
+ it 'should handle rspec (>= 2.2) execution results' do
142
+ failure = CI::Reporter::RSpec2Failure.new(@rspec22_example, @formatter)
143
+ failure.name.should_not be_nil
144
+ failure.message.should == 'rspec2.2 ftw'
145
+ failure.location.should_not be_nil
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ begin
3
+ require 'rspec'
4
+ rescue LoadError
5
+ require 'spec'
6
+ end
7
+
8
+ require 'rspec/autorun' if $0 =~ /rcov$/
9
+
10
+ unless defined?(CI_REPORTER_LIB)
11
+ CI_REPORTER_LIB = File.expand_path(File.dirname(__FILE__) + "/../lib")
12
+ $: << CI_REPORTER_LIB
13
+ end
14
+
15
+ require 'ci/reporter/core'
16
+
17
+ REPORTS_DIR = File.dirname(__FILE__) + "/reports" unless defined?(REPORTS_DIR)
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ci_reporter_rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Sieger
8
+ - Jake Goulding
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.14'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.14'
28
+ - !ruby/object:Gem::Dependency
29
+ name: ci_reporter
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '='
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0.alpha1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.0.alpha1
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.6'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.6'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description:
71
+ email:
72
+ - nick@nicksieger.com
73
+ - jake.goulding@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - acceptance/.gitignore
85
+ - acceptance/rspec_example_spec.rb
86
+ - acceptance/verification_spec.rb
87
+ - ci_reporter_rspec.gemspec
88
+ - gemfiles/.gitignore
89
+ - gemfiles/Gemfile.2.14
90
+ - lib/ci/reporter/rake/rspec.rb
91
+ - lib/ci/reporter/rake/rspec_loader.rb
92
+ - lib/ci/reporter/rspec.rb
93
+ - lib/ci/reporter/rspec/version.rb
94
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
95
+ - spec/ci/reporter/rspec_spec.rb
96
+ - spec/spec_helper.rb
97
+ homepage: https://github.com/ci-reporter/ci_reporter_rspec
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.2.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Connects CI::Reporter to RSpec
121
+ test_files:
122
+ - acceptance/.gitignore
123
+ - acceptance/rspec_example_spec.rb
124
+ - acceptance/verification_spec.rb
125
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
126
+ - spec/ci/reporter/rspec_spec.rb
127
+ - spec/spec_helper.rb