petitest-tap 0.1.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa31a8323eb9bc269b429628e02a1a21971f34ca
4
+ data.tar.gz: fc1892bf797ba144e9f0aae00f28343f3d569405
5
+ SHA512:
6
+ metadata.gz: f33ec24df8cfd95bca3c10ffe5669a4cd3b9a694ca7d53fcd76ff5f9fbec9ebd7494b6606e197d8b5910b8c4e1f6c0e06a77caafb2c251c880c31720485c1285
7
+ data.tar.gz: 6d01b22a85ac1af631f8f5fc5fe4faddb09f111d7848d4170c376004fc4f4049a7e785bf2d11edff77877af18d0cac730c6a5ae6783e989d8b2e747298d82448
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
@@ -0,0 +1,3 @@
1
+ ## v0.1.3
2
+
3
+ - 1st Release :tada:
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in petitest-tap.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Ryo Nakamura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Petitest::Tap
2
+
3
+ TAP output for [Petitest](https://github.com/petitest/petitest).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application"s Gemfile:
8
+
9
+ ```ruby
10
+ gem "petitest-tap"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ gem install petitest-tap
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ 1. Require `petitest/tap`
28
+ 2. Change `Petitest.configuration.subscribers`
29
+ 3. Run tests
30
+
31
+ ```ruby
32
+ require "petitest/tap"
33
+ Petitest.configuration.subscribers = [Petitest::Tap::Subscriber.new]
34
+ ```
35
+
36
+ ### nyan
37
+
38
+ Demo with https://github.com/calvinmetcalf/tap-nyan:
39
+
40
+ ![demo](/images/demo.gif)
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
Binary file
@@ -0,0 +1,3 @@
1
+ require "petitest/tap/subscriber"
2
+ require "petitest/tap/texts/test_case_text"
3
+ require "petitest/tap/version"
@@ -0,0 +1,44 @@
1
+ require "petitest/subscribers/base_subscriber"
2
+ require "petitest/subscriber_concerns/output_concern"
3
+
4
+ module Petitest
5
+ module Tap
6
+ class Subscriber < ::Petitest::Subscribers::BaseSubscriber
7
+ include ::Petitest::SubscriberConcerns::OutputConcern
8
+
9
+ attr_writer :index
10
+
11
+ # @note Override
12
+ def after_running_test_case(test_case)
13
+ super
14
+ string = ::Petitest::Tap::Texts::TestCaseText.new(
15
+ index: index,
16
+ test_case: test_case,
17
+ ).to_s
18
+ output.puts(string)
19
+ ensure
20
+ increment
21
+ end
22
+
23
+ # @note Override
24
+ def before_running_test_cases(test_cases)
25
+ super
26
+ string = [
27
+ "TAP version 13",
28
+ "1..#{test_cases.length}",
29
+ ].join("\n")
30
+ output.puts(string)
31
+ end
32
+
33
+ # @return [Integer]
34
+ def increment
35
+ self.index += 1
36
+ end
37
+
38
+ # @return [Integer]
39
+ def index
40
+ @index || 0
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,52 @@
1
+ module Petitest
2
+ module Tap
3
+ module Texts
4
+ class TestCaseText
5
+ NOT_OK = "not ok"
6
+ OK = "ok"
7
+ SKIP_DIRECTIVE = " # SKIP"
8
+
9
+ # @param index [Integer]
10
+ # @param test_case [Petitest::TestCase]
11
+ def initialize(index:, test_case:)
12
+ @index = index
13
+ @test_case = test_case
14
+ end
15
+
16
+ # @note Override
17
+ def to_s
18
+ string = "#{ok_or_not_ok} #{test_number} - #{description}"
19
+ string += SKIP_DIRECTIVE if test_case.skipped?
20
+ string
21
+ end
22
+
23
+ private
24
+
25
+ # @return [String]
26
+ def description
27
+ test_case.test_signature
28
+ end
29
+
30
+ # @return [Integer]
31
+ def index
32
+ @index
33
+ end
34
+
35
+ # @return [String]
36
+ def ok_or_not_ok
37
+ test_case.passed? ? OK : NOT_OK
38
+ end
39
+
40
+ # @return [Petitest::TestCase]
41
+ def test_case
42
+ @test_case
43
+ end
44
+
45
+ # @return [Integer]
46
+ def test_number
47
+ index + 1
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ module Petitest
2
+ module Tap
3
+ VERSION = "0.1.3"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "petitest/tap/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "petitest-tap"
7
+ spec.version = Petitest::Tap::VERSION
8
+ spec.authors = ["Ryo Nakamura"]
9
+ spec.email = ["r7kamura@gmail.com"]
10
+ spec.summary = "TAP output for Petitest."
11
+ spec.homepage = "https://github.com/petitest/petitest"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "petitest", ">= 0.1.3"
21
+ spec.add_development_dependency "bundler", "~> 1.14"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: petitest-tap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Ryo Nakamura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: petitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - r7kamura@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CHANGELOG.md
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - images/demo.gif
83
+ - lib/petitest/tap.rb
84
+ - lib/petitest/tap/subscriber.rb
85
+ - lib/petitest/tap/texts/test_case_text.rb
86
+ - lib/petitest/tap/version.rb
87
+ - petitest-tap.gemspec
88
+ homepage: https://github.com/petitest/petitest
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.5.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: TAP output for Petitest.
112
+ test_files: []