rspec-legacy_formatters 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +16 -0
- data/.yardopts +7 -0
- data/Changelog.md +3 -0
- data/Gemfile +30 -0
- data/License.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +27 -0
- data/cucumber.yml +6 -0
- data/features/custom_formatter.feature +28 -0
- data/features/regression_tests_for_built_in_formatters.feature +86 -0
- data/features/regression_tests_for_custom_formatters.feature +94 -0
- data/features/step_definitions/additional_cli_steps.rb +4 -0
- data/features/support/env.rb +13 -0
- data/lib/rspec/legacy_formatters.rb +59 -0
- data/lib/rspec/legacy_formatters/adaptor.rb +230 -0
- data/lib/rspec/legacy_formatters/base_formatter.rb +248 -0
- data/lib/rspec/legacy_formatters/base_text_formatter.rb +330 -0
- data/lib/rspec/legacy_formatters/documentation_formatter.rb +69 -0
- data/lib/rspec/legacy_formatters/helpers.rb +108 -0
- data/lib/rspec/legacy_formatters/html_formatter.rb +157 -0
- data/lib/rspec/legacy_formatters/html_printer.rb +412 -0
- data/lib/rspec/legacy_formatters/json_formatter.rb +71 -0
- data/lib/rspec/legacy_formatters/progress_formatter.rb +31 -0
- data/lib/rspec/legacy_formatters/snippet_extractor.rb +92 -0
- data/lib/rspec/legacy_formatters/version.rb +9 -0
- data/maintenance-branch +1 -0
- data/rspec-legacy_formatters.gemspec +43 -0
- data/script/functions.sh +144 -0
- data/script/run_build +13 -0
- data/spec/rspec/legacy_formatters_spec.rb +184 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/formatter_support.rb +83 -0
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +87 -0
- data/spec/support/old_style_formatter_example.rb +69 -0
- metadata +243 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e497032757ef52f1b99a17d71f81f1666e80698f
|
4
|
+
data.tar.gz: 7fc2b3298d1196c86af0692ac57a13b513d985be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48d126abc7927b049e65cb4c155e8b91688b032c3e2e242ab3ff2b7cd658babd3e6bf75a553b0991861010bf5956405b01a9a2a2797be57da62a6cef84c8ea12
|
7
|
+
data.tar.gz: e925aa53cbbca05cbfe021082cfd43ef89ca40b8cb5c4b967cd3d88f2ff5a6077fd66c7fa542554d8f6273aa5e31179c7221b965e8dbf2762d647a9f1a7091d2
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Zb�h�/������hH6�E��d,3D�����ٍ.Й;�1z}-���FҞ�5��@�i�"�{4&�� N�����:���%�,��6��K��z+�7HZ��F������H�ʪ�0����=���@C�|tVj5�;�P���p��s�����<�阓��F��y<Մ�I^�ک�����~GR��b�p�Ӳ�i�K�r�e��d{C�F����)s��:"J���$���lA�ȟ�e������D���RQh
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated on 2014-03-30T13:16:22-07:00 from the rspec-dev repo.
|
2
|
+
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
|
3
|
+
|
4
|
+
bundler_args: "--binstubs --standalone --without documentation --path ../bundle"
|
5
|
+
script: "script/run_build"
|
6
|
+
rvm:
|
7
|
+
- 1.8.7
|
8
|
+
- 1.9.2
|
9
|
+
- 1.9.3
|
10
|
+
- 2.0.0
|
11
|
+
- 2.1.0
|
12
|
+
- 2.1.1
|
13
|
+
- ree
|
14
|
+
- jruby-18mode
|
15
|
+
- jruby
|
16
|
+
- rbx
|
data/.yardopts
ADDED
data/Changelog.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
%w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
|
6
|
+
library_path = File.expand_path("../../#{lib}", __FILE__)
|
7
|
+
if File.exist?(library_path) && !ENV['USE_GIT_REPOS']
|
8
|
+
gem lib, :path => library_path
|
9
|
+
else
|
10
|
+
gem lib, :git => "git://github.com/rspec/#{lib}.git"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
### deps for rdoc.info
|
15
|
+
platforms :ruby do
|
16
|
+
gem 'redcarpet', '2.1.1'
|
17
|
+
gem 'github-markup', '0.7.2'
|
18
|
+
end
|
19
|
+
|
20
|
+
gem 'simplecov', '~> 0.8'
|
21
|
+
|
22
|
+
platforms :ruby_18, :jruby do
|
23
|
+
gem 'json'
|
24
|
+
end
|
25
|
+
|
26
|
+
platforms :jruby do
|
27
|
+
gem "jruby-openssl"
|
28
|
+
end
|
29
|
+
|
30
|
+
eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
|
data/License.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2014 The RSpec Development Team
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# RSpec::LegacyFormatters
|
2
|
+
|
3
|
+
This gem provides support for using legacy formatters (that is, those
|
4
|
+
that were written against the RSpec 2 formatter API) with RSpec 3.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'rspec-legacy_formatters'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install rspec-legacy_formatters
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
This gem MUST be required before the legacy formatter is loaded. We recommend
|
23
|
+
you use RSpec's `--require` option, either from the command line:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ rspec --require rspec/legacy_formatters --format MyCustomFormatter
|
27
|
+
```
|
28
|
+
|
29
|
+
...or by adding it to `.rspec`:
|
30
|
+
|
31
|
+
```
|
32
|
+
--require rspec/legacy_formatters
|
33
|
+
```
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( http://github.com/<my-github-username>/rspec-legacy_formatters/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require "rake"
|
6
|
+
|
7
|
+
require "rspec/core/rake_task"
|
8
|
+
require "rspec/legacy_formatters/version"
|
9
|
+
|
10
|
+
require "cucumber/rake/task"
|
11
|
+
Cucumber::Rake::Task.new(:cucumber)
|
12
|
+
|
13
|
+
desc "Run all examples"
|
14
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
15
|
+
t.ruby_opts = %w[-w]
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => [:spec, :cucumber]
|
19
|
+
|
20
|
+
task :verify_private_key_present do
|
21
|
+
private_key = File.expand_path('~/.gem/rspec-gem-private_key.pem')
|
22
|
+
unless File.exist?(private_key)
|
23
|
+
raise "Your private key is not present. This gem should not be built without that."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
task :build => :verify_private_key_present
|
data/cucumber.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Custom formatters
|
2
|
+
|
3
|
+
Scenario: a legacy custom formatter
|
4
|
+
Given a file named "custom_formatter.rb" with:
|
5
|
+
"""ruby
|
6
|
+
require "rspec/legacy_formatters"
|
7
|
+
require "rspec/core/formatters/base_text_formatter"
|
8
|
+
|
9
|
+
class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
|
10
|
+
def initialize(output)
|
11
|
+
super(output)
|
12
|
+
end
|
13
|
+
|
14
|
+
def example_started(proxy)
|
15
|
+
output << "example: " << proxy.description
|
16
|
+
end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
And a file named "example_spec.rb" with:
|
20
|
+
"""ruby
|
21
|
+
describe "my group" do
|
22
|
+
specify "my example" do
|
23
|
+
end
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
When I run `rspec example_spec.rb --require ./custom_formatter.rb --format CustomFormatter`
|
27
|
+
Then the output should contain "example: my example"
|
28
|
+
And the exit status should be 0
|
@@ -0,0 +1,86 @@
|
|
1
|
+
Feature: Regression tests for built in formatters
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named ".rspec" with:
|
5
|
+
"""
|
6
|
+
--require rspec/legacy_formatters
|
7
|
+
--require spec_helper
|
8
|
+
"""
|
9
|
+
And a file named "spec/spec_helper.rb" with:
|
10
|
+
"""
|
11
|
+
RSpec.configure do |rspec|
|
12
|
+
rspec.raise_errors_for_deprecations!
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
And a file named "spec/passing_and_failing_spec.rb" with:
|
16
|
+
"""ruby
|
17
|
+
RSpec.shared_examples "shared" do
|
18
|
+
it "fails" do
|
19
|
+
expect(1).to eq(2)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.describe "Some examples" do
|
24
|
+
it "passes" do
|
25
|
+
expect(1).to eq(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "fails" do
|
29
|
+
expect(1).to eq(2)
|
30
|
+
end
|
31
|
+
|
32
|
+
it_behaves_like "shared"
|
33
|
+
|
34
|
+
context "nested" do
|
35
|
+
it "passes" do
|
36
|
+
expect(1).to eq(1)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "fails" do
|
40
|
+
expect(1).to eq(2)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
"""
|
45
|
+
And a file named "spec/pending_spec.rb" with:
|
46
|
+
"""ruby
|
47
|
+
RSpec.describe "Some pending examples" do
|
48
|
+
context "pending" do
|
49
|
+
it "is reported as pending" do
|
50
|
+
pending; expect(1).to eq(2)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "is reported as failing" do
|
54
|
+
pending; expect(1).to eq(1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
"""
|
59
|
+
|
60
|
+
Scenario: Use progress formatter with profiling
|
61
|
+
When I run `rspec --format progress --profile --order defined`
|
62
|
+
Then the output should contain ".FF.F*F"
|
63
|
+
And the output should contain "7 examples, 4 failures, 1 pending"
|
64
|
+
And the output should not contain any error backtraces
|
65
|
+
|
66
|
+
Scenario: Use doc formatter with profiling
|
67
|
+
When I run `rspec --format doc --profile --order defined`
|
68
|
+
Then the output should contain "is reported as pending (PENDING: No reason given)"
|
69
|
+
And the output should contain "7 examples, 4 failures, 1 pending"
|
70
|
+
And the output should not contain any error backtraces
|
71
|
+
|
72
|
+
Scenario: Use json formatter with profiling
|
73
|
+
When I run `rspec --format json --profile --order defined`
|
74
|
+
Then the output should contain:
|
75
|
+
"""
|
76
|
+
"examples":
|
77
|
+
"""
|
78
|
+
And the output should contain "7 examples, 4 failures, 1 pending"
|
79
|
+
|
80
|
+
Scenario: Use html formatter with profiling
|
81
|
+
When I run `rspec --format html --profile --order defined`
|
82
|
+
Then the output should contain:
|
83
|
+
"""
|
84
|
+
<span class="comment"># gem install syntax to get syntax highlighting</span>
|
85
|
+
"""
|
86
|
+
And the output should contain "7 examples, 4 failures, 1 pending"
|
@@ -0,0 +1,94 @@
|
|
1
|
+
Feature: Regression tests for legacy custom formatters
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named ".rspec" with:
|
5
|
+
"""
|
6
|
+
--require rspec/legacy_formatters
|
7
|
+
--require spec_helper
|
8
|
+
"""
|
9
|
+
And a file named "spec/spec_helper.rb" with:
|
10
|
+
"""
|
11
|
+
# Shelling out to `stty` doesn't work in aruba, so we fake out nyancat formatter
|
12
|
+
# to make it avoid that. See here:
|
13
|
+
# https://github.com/mattsears/nyan-cat-formatter/blob/704b9f7718eea1620175551b8ac8abec59dd0f86/lib/nyan_cat_formatter.rb#L94-L98
|
14
|
+
JRUBY_VERSION = 'something'
|
15
|
+
|
16
|
+
RSpec.configure do |rspec|
|
17
|
+
rspec.after(:suite) do
|
18
|
+
puts rspec.formatters.map(&:class).inspect
|
19
|
+
end
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
And a file named "spec/passing_and_failing_spec.rb" with:
|
23
|
+
"""ruby
|
24
|
+
RSpec.describe "Some examples" do
|
25
|
+
it "passes" do
|
26
|
+
expect(1).to eq(1)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "fails" do
|
30
|
+
expect(1).to eq(2)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "nested" do
|
34
|
+
it "passes" do
|
35
|
+
expect(1).to eq(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "fails" do
|
39
|
+
expect(1).to eq(2)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
And a file named "spec/pending_spec.rb" with:
|
45
|
+
"""ruby
|
46
|
+
RSpec.describe "Some pending examples" do
|
47
|
+
context "pending" do
|
48
|
+
it "is reported as pending" do
|
49
|
+
pending; expect(1).to eq(2)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is reported as failing" do
|
53
|
+
pending; expect(1).to eq(1)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
"""
|
58
|
+
|
59
|
+
Scenario: Use fuubar formatter
|
60
|
+
When I run `rspec --format Fuubar`
|
61
|
+
Then the output should contain "Progress: |============"
|
62
|
+
And the output should contain "6 examples, 3 failures, 1 pending"
|
63
|
+
And the output should not contain any error backtraces
|
64
|
+
And the output should not contain "ProgressFormatter"
|
65
|
+
|
66
|
+
Scenario: Use rspec-instafail formatter
|
67
|
+
When I run `rspec --format RSpec::Instafail`
|
68
|
+
Then the output should contain "6 examples, 3 failures, 1 pending"
|
69
|
+
And the output should not contain any error backtraces
|
70
|
+
And the output should not contain "ProgressFormatter"
|
71
|
+
|
72
|
+
Scenario: Use rspec-extra-formatters JUnit formatter
|
73
|
+
When I run `rspec --require rspec-extra-formatters --format JUnitFormatter`
|
74
|
+
Then the output should contain:
|
75
|
+
"""
|
76
|
+
<testsuite errors="0" failures="3" skipped="1" tests="6"
|
77
|
+
"""
|
78
|
+
And the output should not contain any error backtraces
|
79
|
+
And the output should not contain "ProgressFormatter"
|
80
|
+
|
81
|
+
Scenario: Use rspec-extra-formatters Tap formatter
|
82
|
+
When I run `rspec --require rspec-extra-formatters --format TapFormatter`
|
83
|
+
Then the output should contain "TAP version 13"
|
84
|
+
And the output should not contain any error backtraces
|
85
|
+
And the output should not contain "ProgressFormatter"
|
86
|
+
|
87
|
+
Scenario: Use fivemat formatter
|
88
|
+
When I run `rspec --format Fivemat --order defined`
|
89
|
+
Then the output should contain "Some examples .F.F"
|
90
|
+
And the output should not contain "ProgressFormatter"
|
91
|
+
|
92
|
+
Scenario: Use nyancat formatter
|
93
|
+
When I run `rspec --format NyanCatFormatter`
|
94
|
+
Then the output should contain "6/6: -*_*+*"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
|
3
|
+
timeouts = { 'java' => 60 }
|
4
|
+
|
5
|
+
Before do
|
6
|
+
@aruba_timeout_seconds = timeouts.fetch(RUBY_PLATFORM) { 10 }
|
7
|
+
end
|
8
|
+
|
9
|
+
Aruba.configure do |config|
|
10
|
+
config.before_cmd do |cmd|
|
11
|
+
set_env('JRUBY_OPTS', "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
|
12
|
+
end
|
13
|
+
end if RUBY_PLATFORM == 'java'
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "rspec/legacy_formatters/version"
|
2
|
+
require "rspec/legacy_formatters/adaptor"
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
# Require all of rspec-core's formatters (and supporting files).
|
6
|
+
# We do this so that if a legacy formatter gem requires any of
|
7
|
+
# these files, it'll be a no-op (as the file will have already
|
8
|
+
# been required). If we didn't do this, and one of the rspec-core
|
9
|
+
# formatters got loaded after our definition here, it could stomp
|
10
|
+
# our definition.
|
11
|
+
%w[
|
12
|
+
base_formatter
|
13
|
+
base_text_formatter
|
14
|
+
console_codes
|
15
|
+
deprecation_formatter
|
16
|
+
documentation_formatter
|
17
|
+
helpers
|
18
|
+
html_formatter
|
19
|
+
html_printer
|
20
|
+
json_formatter
|
21
|
+
progress_formatter
|
22
|
+
snippet_extractor
|
23
|
+
].each do |formatter_file|
|
24
|
+
require "rspec/core/formatters/#{formatter_file}"
|
25
|
+
end
|
26
|
+
|
27
|
+
%w[
|
28
|
+
base_formatter
|
29
|
+
base_text_formatter
|
30
|
+
documentation_formatter
|
31
|
+
html_formatter
|
32
|
+
json_formatter
|
33
|
+
progress_formatter
|
34
|
+
].each do |formatter|
|
35
|
+
require "rspec/legacy_formatters/#{formatter}"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Namespace for the rspec code.
|
39
|
+
module RSpec
|
40
|
+
# Namespace for the rspec-legacy_formatters code.
|
41
|
+
module LegacyFormatters
|
42
|
+
|
43
|
+
# Loads legacy formatters into an adaptor.
|
44
|
+
#
|
45
|
+
# @param formatter_class [Class] a legacy formatter class
|
46
|
+
# @param args [Array(IO)] output streams for formatters
|
47
|
+
# @return [Adaptor] a legacy formatter adaptor with an initialized legacy formatter
|
48
|
+
def self.load_formatter(formatter_class, *args)
|
49
|
+
Adaptor.new(formatter_class, *args)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
module Core
|
55
|
+
# Needed for Fivemat.
|
56
|
+
# See https://github.com/rspec/rspec-core/pull/1129
|
57
|
+
PendingExampleFixedError = Pending::PendingExampleFixedError
|
58
|
+
end
|
59
|
+
end
|