ci_reporter_cucumber 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +61 -0
- data/Rakefile +32 -0
- data/acceptance/.gitignore +1 -0
- data/acceptance/cucumber/cucumber_example.feature +19 -0
- data/acceptance/cucumber/step_definitions/development_steps.rb +34 -0
- data/acceptance/verification_spec.rb +38 -0
- data/ci_reporter_cucumber.gemspec +26 -0
- data/lib/ci/reporter/cucumber/version.rb +7 -0
- data/lib/ci/reporter/cucumber.rb +123 -0
- data/lib/ci/reporter/rake/cucumber.rb +13 -0
- data/lib/ci/reporter/rake/cucumber_loader.rb +2 -0
- data/spec/ci/reporter/cucumber_spec.rb +226 -0
- data/spec/ci/reporter/rake/rake_tasks_spec.rb +37 -0
- data/spec/spec_helper.rb +17 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e93cb95d49957071f7d5ea80422c2d7ce69af3fd
|
4
|
+
data.tar.gz: 92c854967c6358888c65c84b2314da3d0fb0bb8c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3eb5f4f053066b8badb22b9a36fa912c553309ccb77c3f8e3af6df07658d25b1e9505a482f12531c2ddb32280247dcb4bc3f2708af16b7c8b716afbece8798a9
|
7
|
+
data.tar.gz: 5f285aed76ea481f074167a65bf2267807ef1653b608edf6d2617470414070553a6ed93bff818322ad21a5ec62d1ac34d74301ac94a6c4e438f65ed0ff09905c
|
data/.gitignore
ADDED
@@ -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
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# CI::Reporter::Cucumber
|
2
|
+
|
3
|
+
Connects [Cucumber][cuke] to [CI::Reporter][ci], and then to your CI
|
4
|
+
system.
|
5
|
+
|
6
|
+
[cuke]: http://cukes.info/
|
7
|
+
[ci]: https://github.com/ci-reporter/ci_reporter
|
8
|
+
|
9
|
+
## Supported versions
|
10
|
+
|
11
|
+
The latest release of Cucumber 1.3 is supported.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'ci_reporter_cucumber'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then install it:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Require the reporter in your Rakefile, and ensure that
|
30
|
+
`ci:setup:cucumber` is a dependency of your RSpec task:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'ci/reporter/rake/cucumber'
|
34
|
+
|
35
|
+
# ...
|
36
|
+
# Rake code that creates a task called `:cucumber`
|
37
|
+
# ...
|
38
|
+
|
39
|
+
task :cucumber => 'ci:setup:cucumber'
|
40
|
+
```
|
41
|
+
|
42
|
+
### Advanced usage
|
43
|
+
|
44
|
+
Refer to the shared [documentation][ci] for details on setting up
|
45
|
+
CI::Reporter.
|
46
|
+
|
47
|
+
### Spinach
|
48
|
+
|
49
|
+
If you use both Cucumber and Spinach, you are likely to see strange
|
50
|
+
errors due to `gherkin` and `gherkin-ruby` both being loaded. Choose
|
51
|
+
only one of these frameworks.
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
1. Fork it ( https://github.com/ci-reporter/ci_reporter_cucumber/fork )
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Add a failing test.
|
58
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
5. Ensure tests pass.
|
60
|
+
6. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
7. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -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 :cucumber do
|
11
|
+
cucumber = "#{Gem.loaded_specs['cucumber'].gem_dir}/bin/cucumber"
|
12
|
+
run_ruby_acceptance "-rci/reporter/rake/cucumber_loader -S #{cucumber} --format CI::Reporter::Cucumber acceptance/cucumber"
|
13
|
+
end
|
14
|
+
|
15
|
+
task :all => [:clean, :cucumber]
|
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,19 @@
|
|
1
|
+
Feature: Example Cucumber feature
|
2
|
+
As a conscientious developer who writes features
|
3
|
+
I want to be able to see my features passing on the CI Server
|
4
|
+
So that I can bask in the glow of a green bar
|
5
|
+
|
6
|
+
Scenario: Conscientious developer
|
7
|
+
Given that I am a conscientious developer
|
8
|
+
And I write cucumber features
|
9
|
+
Then I should see a green bar
|
10
|
+
|
11
|
+
Scenario: Lazy hacker
|
12
|
+
Given that I am a lazy hacker
|
13
|
+
And I don't bother writing cucumber features
|
14
|
+
Then I should be fired
|
15
|
+
|
16
|
+
Scenario: Bad coder
|
17
|
+
Given that I can't code for peanuts
|
18
|
+
And I write step definitions that throw exceptions
|
19
|
+
Then I shouldn't be allowed out in public
|
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'rspec/expectations'
|
3
|
+
rescue LoadError
|
4
|
+
require 'spec/expectations'
|
5
|
+
end
|
6
|
+
|
7
|
+
Given /^that I am a conscientious developer$/ do
|
8
|
+
end
|
9
|
+
|
10
|
+
Given /^I write cucumber features$/ do
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^I should see a green bar$/ do
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /^that I am a lazy hacker$/ do
|
17
|
+
end
|
18
|
+
|
19
|
+
Given /^I don't bother writing cucumber features$/ do
|
20
|
+
false.should be true
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^I should be fired$/ do
|
24
|
+
end
|
25
|
+
|
26
|
+
Given /^that I can't code for peanuts$/ do
|
27
|
+
end
|
28
|
+
|
29
|
+
Given /^I write step definitions that throw exceptions$/ do
|
30
|
+
raise RuntimeError, "User error!"
|
31
|
+
end
|
32
|
+
|
33
|
+
Then /^I shouldn't be allowed out in public$/ do
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
REPORTS_DIR = File.dirname(__FILE__) + '/reports'
|
4
|
+
|
5
|
+
describe "Cucumber acceptance" do
|
6
|
+
it "should generate one XML file" do
|
7
|
+
File.exist?(File.join(REPORTS_DIR, 'FEATURES-Example-Cucumber-feature.xml')).should == true
|
8
|
+
|
9
|
+
Dir["#{REPORTS_DIR}/FEATURES-*Cucumber*.xml"].length.should == 1
|
10
|
+
end
|
11
|
+
|
12
|
+
context "FEATURES report file" do
|
13
|
+
before :each do
|
14
|
+
@doc = File.open(File.join(REPORTS_DIR, 'FEATURES-Example-Cucumber-feature.xml')) do |f|
|
15
|
+
REXML::Document.new(f)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have three tests and two failures" do
|
20
|
+
@doc.root.attributes["errors"].should == "0"
|
21
|
+
@doc.root.attributes["failures"].should == "2"
|
22
|
+
@doc.root.attributes["tests"].should == "3"
|
23
|
+
@doc.root.elements.to_a("/testsuite/testcase").size.should == 3
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have one failure for the lazy hacker" do
|
27
|
+
failures = @doc.root.elements.to_a("/testsuite/testcase[@name='Lazy hacker']/failure")
|
28
|
+
failures.size.should == 1
|
29
|
+
failures.first.attributes["type"].should =~ /ExpectationNotMetError/
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have one failure for the bad coder" do
|
33
|
+
failures = @doc.root.elements.to_a("/testsuite/testcase[@name='Bad coder']/failure")
|
34
|
+
failures.size.should == 1
|
35
|
+
failures.first.attributes["type"].should == "RuntimeError"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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/cucumber/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ci_reporter_cucumber"
|
8
|
+
spec.version = CI::Reporter::Cucumber::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 Cucumber}
|
12
|
+
spec.homepage = "https://github.com/ci-reporter/ci_reporter_cucumber"
|
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 "cucumber", "~> 1.3.3"
|
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
|
+
spec.add_development_dependency "rspec", "~> 2.0"
|
26
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'ci/reporter/core'
|
2
|
+
require 'cucumber'
|
3
|
+
begin
|
4
|
+
require 'cucumber/ast/visitor'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
module CI
|
9
|
+
module Reporter
|
10
|
+
class CucumberFailure
|
11
|
+
attr_reader :step
|
12
|
+
|
13
|
+
def initialize(step)
|
14
|
+
@step = step
|
15
|
+
end
|
16
|
+
|
17
|
+
def failure?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def error?
|
22
|
+
!failure?
|
23
|
+
end
|
24
|
+
|
25
|
+
def name
|
26
|
+
step.exception.class.name
|
27
|
+
end
|
28
|
+
|
29
|
+
def message
|
30
|
+
step.exception.message
|
31
|
+
end
|
32
|
+
|
33
|
+
def location
|
34
|
+
step.exception.backtrace.join("\n")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Cucumber
|
39
|
+
attr_accessor :report_manager, :test_suite, :name
|
40
|
+
|
41
|
+
def initialize(step_mother, io, options)
|
42
|
+
@report_manager = ReportManager.new("features")
|
43
|
+
end
|
44
|
+
|
45
|
+
def before_feature(feature)
|
46
|
+
self.test_suite = TestSuite.new(@name)
|
47
|
+
test_suite.start
|
48
|
+
end
|
49
|
+
|
50
|
+
def after_feature(feature)
|
51
|
+
test_suite.name = @name
|
52
|
+
test_suite.finish
|
53
|
+
report_manager.write_report(@test_suite)
|
54
|
+
@test_suite = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def before_background(*args)
|
58
|
+
end
|
59
|
+
|
60
|
+
def after_background(*args)
|
61
|
+
end
|
62
|
+
|
63
|
+
def feature_name(keyword, name)
|
64
|
+
@name = (name || "Unnamed feature").split("\n").first
|
65
|
+
end
|
66
|
+
|
67
|
+
def scenario_name(keyword, name, *args)
|
68
|
+
@scenario = (name || "Unnamed scenario").split("\n").first
|
69
|
+
end
|
70
|
+
|
71
|
+
def before_steps(steps)
|
72
|
+
@test_case = TestCase.new(@scenario)
|
73
|
+
@test_case.start
|
74
|
+
end
|
75
|
+
|
76
|
+
def after_steps(steps)
|
77
|
+
@test_case.finish
|
78
|
+
|
79
|
+
case steps.status
|
80
|
+
when :pending, :undefined
|
81
|
+
@test_case.name = "#{@test_case.name} (PENDING)"
|
82
|
+
when :skipped
|
83
|
+
@test_case.name = "#{@test_case.name} (SKIPPED)"
|
84
|
+
when :failed
|
85
|
+
@test_case.failures << CucumberFailure.new(steps)
|
86
|
+
end
|
87
|
+
|
88
|
+
test_suite.testcases << @test_case
|
89
|
+
@test_case = nil
|
90
|
+
end
|
91
|
+
|
92
|
+
def before_examples(*args)
|
93
|
+
@header_row = true
|
94
|
+
end
|
95
|
+
|
96
|
+
def after_examples(*args)
|
97
|
+
end
|
98
|
+
|
99
|
+
def before_table_row(table_row)
|
100
|
+
row = table_row # shorthand for table_row
|
101
|
+
# check multiple versions of the row and try to find the best fit
|
102
|
+
outline = (row.respond_to? :name) ? row.name :
|
103
|
+
(row.respond_to? :scenario_outline) ? row.scenario_outline :
|
104
|
+
row.to_s
|
105
|
+
@test_case = TestCase.new("#@scenario (outline: #{outline})")
|
106
|
+
@test_case.start
|
107
|
+
end
|
108
|
+
|
109
|
+
def after_table_row(table_row)
|
110
|
+
if @header_row
|
111
|
+
@header_row = false
|
112
|
+
return
|
113
|
+
end
|
114
|
+
@test_case.finish
|
115
|
+
if table_row.respond_to? :failed?
|
116
|
+
@test_case.failures << CucumberFailure.new(table_row) if table_row.failed?
|
117
|
+
test_suite.testcases << @test_case
|
118
|
+
@test_case = nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'ci/reporter/rake/utils'
|
2
|
+
|
3
|
+
namespace :ci do
|
4
|
+
namespace :setup do
|
5
|
+
task :cucumber_report_cleanup do
|
6
|
+
rm_rf ENV["CI_REPORTS"] || "features/reports"
|
7
|
+
end
|
8
|
+
|
9
|
+
task :cucumber => :cucumber_report_cleanup do
|
10
|
+
ENV["CUCUMBER_OPTS"] = "#{ENV['CUCUMBER_OPTS']} --format CI::Reporter::Cucumber"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper.rb"
|
2
|
+
require 'ci/reporter/cucumber'
|
3
|
+
|
4
|
+
describe "The Cucumber reporter" do
|
5
|
+
describe CI::Reporter::CucumberFailure do
|
6
|
+
before(:each) do
|
7
|
+
@klass = double("class")
|
8
|
+
@klass.stub(:name).and_return("Exception name")
|
9
|
+
|
10
|
+
@exception = double("exception")
|
11
|
+
@exception.stub(:class).and_return(@klass)
|
12
|
+
@exception.stub(:message).and_return("Exception message")
|
13
|
+
@exception.stub(:backtrace).and_return(["First line", "Second line"])
|
14
|
+
|
15
|
+
@step = double("step")
|
16
|
+
@step.stub(:exception).and_return(@exception)
|
17
|
+
|
18
|
+
@cucumber_failure = CI::Reporter::CucumberFailure.new(@step)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should always return true for failure?" do
|
22
|
+
@cucumber_failure.should be_failure
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should always return false for error?" do
|
26
|
+
@cucumber_failure.should_not be_error
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should propagate the name as the underlying exception's class name" do
|
30
|
+
@step.should_receive(:exception)
|
31
|
+
@exception.should_receive(:class)
|
32
|
+
@klass.should_receive(:name)
|
33
|
+
|
34
|
+
@cucumber_failure.name.should == "Exception name"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should propagate the message as the underlying exception's message" do
|
38
|
+
@step.should_receive(:exception)
|
39
|
+
@exception.should_receive(:message)
|
40
|
+
|
41
|
+
@cucumber_failure.message.should == "Exception message"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should propagate and format the exception's backtrace" do
|
45
|
+
@step.should_receive(:exception)
|
46
|
+
@exception.should_receive(:backtrace)
|
47
|
+
|
48
|
+
@cucumber_failure.location.should == "First line\nSecond line"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe CI::Reporter::Cucumber do
|
53
|
+
before(:each) do
|
54
|
+
@step_mother = double("step_mother")
|
55
|
+
@io = double("io")
|
56
|
+
|
57
|
+
@report_manager = double("report_manager")
|
58
|
+
CI::Reporter::ReportManager.stub(:new).and_return(@report_manager)
|
59
|
+
end
|
60
|
+
|
61
|
+
def new_instance
|
62
|
+
CI::Reporter::Cucumber.new(@step_mother, @io, {})
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should create a new report manager to report on test success/failure" do
|
66
|
+
CI::Reporter::ReportManager.should_receive(:new)
|
67
|
+
new_instance
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should record the feature name when a new feature is visited" do
|
71
|
+
cucumber = new_instance
|
72
|
+
cucumber.feature_name(nil, "Some feature name")
|
73
|
+
cucumber.name.should == "Some feature name"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should record only the first line of a feature name" do
|
77
|
+
cucumber = new_instance
|
78
|
+
cucumber.feature_name(nil, "Some feature name\nLonger description")
|
79
|
+
cucumber.name.should == "Some feature name"
|
80
|
+
end
|
81
|
+
|
82
|
+
context "applied to a feature" do
|
83
|
+
before(:each) do
|
84
|
+
@cucumber = new_instance
|
85
|
+
@cucumber.feature_name(nil, "Demo feature")
|
86
|
+
|
87
|
+
@test_suite = double("test_suite", :start => nil, :finish => nil, :name= => nil)
|
88
|
+
CI::Reporter::TestSuite.stub(:new).and_return(@test_suite)
|
89
|
+
|
90
|
+
@feature = double("feature")
|
91
|
+
|
92
|
+
@report_manager.stub(:write_report)
|
93
|
+
end
|
94
|
+
|
95
|
+
context "before" do
|
96
|
+
it "should create a new test suite" do
|
97
|
+
CI::Reporter::TestSuite.should_receive(:new).with(/Demo feature/)
|
98
|
+
@cucumber.before_feature(@feature)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should indicate that the test suite has started" do
|
102
|
+
@test_suite.should_receive(:start)
|
103
|
+
@cucumber.before_feature(@feature)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "after" do
|
108
|
+
before :each do
|
109
|
+
@cucumber = new_instance
|
110
|
+
@cucumber.feature_name(nil, "Demo feature")
|
111
|
+
|
112
|
+
@test_suite = double("test_suite", :start => nil, :finish => nil, :name= => nil)
|
113
|
+
CI::Reporter::TestSuite.stub(:new).and_return(@test_suite)
|
114
|
+
|
115
|
+
@feature = double("feature")
|
116
|
+
|
117
|
+
@report_manager.stub(:write_report)
|
118
|
+
|
119
|
+
@cucumber.before_feature(@feature)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should indicate that the test suite has finished" do
|
123
|
+
@test_suite.should_receive(:finish)
|
124
|
+
@cucumber.after_feature(@feature)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should ask the report manager to write a report" do
|
128
|
+
@report_manager.should_receive(:write_report).with(@test_suite)
|
129
|
+
@cucumber.after_feature(@feature)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "inside a scenario" do
|
135
|
+
before(:each) do
|
136
|
+
@testcases = []
|
137
|
+
|
138
|
+
@test_suite = double("test_suite", :testcases => @testcases)
|
139
|
+
|
140
|
+
@cucumber = new_instance
|
141
|
+
@cucumber.stub(:test_suite).and_return(@test_suite)
|
142
|
+
|
143
|
+
@test_case = double("test_case", :start => nil, :finish => nil, :name => "Step Name")
|
144
|
+
CI::Reporter::TestCase.stub(:new).and_return(@test_case)
|
145
|
+
|
146
|
+
@step = double("step", :status => :passed)
|
147
|
+
@step.stub(:name).and_return("Step Name")
|
148
|
+
end
|
149
|
+
|
150
|
+
context "before steps" do
|
151
|
+
it "should create a new test case" do
|
152
|
+
CI::Reporter::TestCase.should_receive(:new).with("Step Name")
|
153
|
+
@cucumber.scenario_name(nil, "Step Name")
|
154
|
+
@cucumber.before_steps(@step)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should indicate that the test case has started" do
|
158
|
+
@test_case.should_receive(:start)
|
159
|
+
@cucumber.before_steps(@step)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context "after steps" do
|
164
|
+
before :each do
|
165
|
+
@cucumber.before_steps(@step)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should indicate that the test case has finished" do
|
169
|
+
@test_case.should_receive(:finish)
|
170
|
+
@cucumber.after_steps(@step)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should add the test case to the suite's list of cases" do
|
174
|
+
@testcases.should be_empty
|
175
|
+
@cucumber.after_steps(@step)
|
176
|
+
@testcases.should_not be_empty
|
177
|
+
@testcases.first.should == @test_case
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should alter the name of a test case that is pending to include '(PENDING)'" do
|
181
|
+
@step.stub(:status).and_return(:pending)
|
182
|
+
@test_case.should_receive(:name=).with("Step Name (PENDING)")
|
183
|
+
@cucumber.after_steps(@step)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should alter the name of a test case that is undefined to include '(PENDING)'" do
|
187
|
+
@step.stub(:status).and_return(:undefined)
|
188
|
+
@test_case.should_receive(:name=).with("Step Name (PENDING)")
|
189
|
+
@cucumber.after_steps(@step)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should alter the name of a test case that was skipped to include '(SKIPPED)'" do
|
193
|
+
@step.stub(:status).and_return(:skipped)
|
194
|
+
@test_case.should_receive(:name=).with("Step Name (SKIPPED)")
|
195
|
+
@cucumber.after_steps(@step)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "that fails" do
|
200
|
+
before(:each) do
|
201
|
+
@step.stub(:status).and_return(:failed)
|
202
|
+
|
203
|
+
@failures = []
|
204
|
+
@test_case.stub(:failures).and_return(@failures)
|
205
|
+
|
206
|
+
@cucumber.before_steps(@step)
|
207
|
+
|
208
|
+
@cucumber_failure = double("cucumber_failure")
|
209
|
+
CI::Reporter::CucumberFailure.stub(:new).and_return(@cucumber_failure)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should create a new cucumber failure with that step" do
|
213
|
+
CI::Reporter::CucumberFailure.should_receive(:new).with(@step)
|
214
|
+
@cucumber.after_steps(@step)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should add the failure to the suite's list of failures" do
|
218
|
+
@failures.should be_empty
|
219
|
+
@cucumber.after_steps(@step)
|
220
|
+
@failures.should_not be_empty
|
221
|
+
@failures.first.should == @cucumber_failure
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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:cucumber task" do
|
8
|
+
before(:each) do
|
9
|
+
@rake = Rake::Application.new
|
10
|
+
Rake.application = @rake
|
11
|
+
load CI_REPORTER_LIB + '/ci/reporter/rake/cucumber.rb'
|
12
|
+
save_env "CI_REPORTS"
|
13
|
+
save_env "CUCUMBER_OPTS"
|
14
|
+
ENV["CI_REPORTS"] = "some-bogus-nonexistent-directory-that-wont-fail-rm_rf"
|
15
|
+
end
|
16
|
+
after(:each) do
|
17
|
+
restore_env "CUCUMBER_OPTS"
|
18
|
+
restore_env "CI_REPORTS"
|
19
|
+
Rake.application = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should set ENV['CUCUMBER_OPTS'] to include cucumber formatter args" do
|
23
|
+
@rake["ci:setup:cucumber"].invoke
|
24
|
+
ENV["CUCUMBER_OPTS"].should =~ /--format\s+CI::Reporter::Cucumber/
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not set ENV['CUCUMBER_OPTS'] to require cucumber_loader" do
|
28
|
+
@rake["ci:setup:cucumber"].invoke
|
29
|
+
ENV["CUCUMBER_OPTS"].should_not =~ /.*--require\s+\S*cucumber_loader.*/
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should append to ENV['CUCUMBER_OPTS'] if it already contains a value" do
|
33
|
+
ENV["CUCUMBER_OPTS"] = "somevalue".freeze
|
34
|
+
@rake["ci:setup:cucumber"].invoke
|
35
|
+
ENV["CUCUMBER_OPTS"].should =~ /somevalue.*\s--format\s+CI::Reporter::Cucumber/
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ci_reporter_cucumber
|
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: cucumber
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.3.3
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.3.3
|
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
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.0'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- nick@nicksieger.com
|
87
|
+
- jake.goulding@gmail.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- acceptance/.gitignore
|
99
|
+
- acceptance/cucumber/cucumber_example.feature
|
100
|
+
- acceptance/cucumber/step_definitions/development_steps.rb
|
101
|
+
- acceptance/verification_spec.rb
|
102
|
+
- ci_reporter_cucumber.gemspec
|
103
|
+
- lib/ci/reporter/cucumber.rb
|
104
|
+
- lib/ci/reporter/cucumber/version.rb
|
105
|
+
- lib/ci/reporter/rake/cucumber.rb
|
106
|
+
- lib/ci/reporter/rake/cucumber_loader.rb
|
107
|
+
- spec/ci/reporter/cucumber_spec.rb
|
108
|
+
- spec/ci/reporter/rake/rake_tasks_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
homepage: https://github.com/ci-reporter/ci_reporter_cucumber
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.2.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Connects CI::Reporter to Cucumber
|
134
|
+
test_files:
|
135
|
+
- acceptance/.gitignore
|
136
|
+
- acceptance/cucumber/cucumber_example.feature
|
137
|
+
- acceptance/cucumber/step_definitions/development_steps.rb
|
138
|
+
- acceptance/verification_spec.rb
|
139
|
+
- spec/ci/reporter/cucumber_spec.rb
|
140
|
+
- spec/ci/reporter/rake/rake_tasks_spec.rb
|
141
|
+
- spec/spec_helper.rb
|