rspec_honeycomb_formatter 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 15eca023c29babb6b13ec87dac5c0276013251a079f2bdd459b1c9aaa45cddfb
4
+ data.tar.gz: 1b3b44ecd7437411d4247bf0de972251054ff2d8ac5f556ddd549c9daf140026
5
+ SHA512:
6
+ metadata.gz: 8b424130f975bf124cc57e2e67e5c1d2745048372e25fcf712cdc18c83971568c6fbe388c42579ef5100b8e73c6c6e3e1f1050e618e2f05964ecb0987638730f
7
+ data.tar.gz: c2859128a91a4f1c1676000d75821ae16c2b9daafc799badfa12257d24b7f952bc832b98ddcfbfce650bc862c7317adb74356a0c0c3eb6ae1fe969a2cccd6101
@@ -0,0 +1,2 @@
1
+ # Setting ownership to the modules team
2
+ * @puppetlabs/modules
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --format RSpecHoneycombFormatter
data/.rubocop.yml ADDED
@@ -0,0 +1,142 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ # binstubs, and other utilities
7
+ - bin/**/*
8
+ - vendor/**/*
9
+ - vendor/**/.*
10
+ # package testing gems
11
+ - package-testing/vendor/**/*
12
+ - package-testing/vendor/**/.*
13
+
14
+ # Metrics, excludes complexity and sizing metrics for now, as ruby's defaults are very strict
15
+ Metrics/AbcSize:
16
+ Enabled: False
17
+
18
+ Metrics/BlockLength:
19
+ Description: rspec uses long describe blocks, so allow long blocks under spec/
20
+ Enabled: False
21
+ Exclude:
22
+ - 'spec/**/*.rb'
23
+
24
+ Metrics/ClassLength:
25
+ Enabled: False
26
+
27
+ Metrics/CyclomaticComplexity:
28
+ Enabled: False
29
+
30
+ Layout/LineLength:
31
+ Description: People have wide screens, use them.
32
+ Max: 200
33
+
34
+ Metrics/MethodLength:
35
+ Enabled: False
36
+
37
+ Metrics/ModuleLength:
38
+ Enabled: False
39
+
40
+ Metrics/ParameterLists:
41
+ Enabled: False
42
+
43
+ Metrics/PerceivedComplexity:
44
+ Enabled: False
45
+
46
+ # RSpec cops
47
+ RSpec/BeforeAfterAll:
48
+ Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing.
49
+ Exclude:
50
+ - 'spec/acceptance/**/*.rb'
51
+ - 'package-testing/spec/package/**/*.rb'
52
+
53
+ RSpec/DescribeClass:
54
+ Description: This cop does not account for rspec-puppet, and beaker-rspec usage.
55
+ Enabled: False
56
+
57
+ RSpec/HookArgument:
58
+ Description: Prefer explicit :each argument, matching existing module's style
59
+ EnforcedStyle: each
60
+
61
+ RSpec/NestedGroups:
62
+ Description: Nested groups can lead to cleaner tests with less duplication
63
+ Max: 10
64
+
65
+ RSpec/ExampleLength:
66
+ Description: Forcing short examples leads to the creation of one-time use let() helpers
67
+ Enabled: False
68
+
69
+ RSpec/MessageSpies:
70
+ EnforcedStyle: receive
71
+
72
+ RSpec/ScatteredSetup:
73
+ Enabled: False
74
+
75
+ # Style Cops
76
+ Style/AsciiComments:
77
+ Description: Names, non-english speaking communities.
78
+ Enabled: False
79
+
80
+ Style/BlockDelimiters:
81
+ Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then.
82
+ EnforcedStyle: braces_for_chaining
83
+
84
+ Style/ClassAndModuleChildren:
85
+ Description: Compact style reduces the required amount of indentation.
86
+ EnforcedStyle: compact
87
+
88
+ Style/EmptyElse:
89
+ Description: Enforce against empty else clauses, but allow `nil` for clarity.
90
+ EnforcedStyle: empty
91
+
92
+ Style/FormatString:
93
+ Description: Following the main puppet project's style, prefer the % format format.
94
+ EnforcedStyle: percent
95
+
96
+ Style/FormatStringToken:
97
+ Description: Following the main puppet project's style, prefer the simpler template tokens over annotated ones.
98
+ EnforcedStyle: template
99
+
100
+ Style/IfUnlessModifier:
101
+ Description: Post-fix `if` modifiers are hard to parse for newcomers. We don't want to encourage them. Post-fix `unless` modifiers could be nice in some cases, but the Cop doesn't differentiate.
102
+ Enabled: false
103
+
104
+ Style/Lambda:
105
+ Description: Prefer the keyword for easier discoverability.
106
+ EnforcedStyle: literal
107
+
108
+ Style/MethodCalledOnDoEndBlock:
109
+ Enabled: true
110
+
111
+ Style/RegexpLiteral:
112
+ Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
113
+ EnforcedStyle: percent_r
114
+
115
+ Style/SymbolProc:
116
+ Description: SymbolProc notation is not discoverable
117
+ Enabled: false
118
+
119
+ Style/TernaryParentheses:
120
+ Description: Checks for use of parentheses around ternary conditions. Enforce parentheses on complex expressions for better readability, but seriously consider breaking it up.
121
+ EnforcedStyle: require_parentheses_when_complex
122
+
123
+ Style/TrailingCommaInArguments:
124
+ Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer.
125
+ EnforcedStyleForMultiline: comma
126
+
127
+ Style/TrailingCommaInArrayLiteral:
128
+ Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer.
129
+ EnforcedStyleForMultiline: comma
130
+
131
+ Style/TrailingCommaInHashLiteral:
132
+ Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer.
133
+ EnforcedStyleForMultiline: comma
134
+
135
+ Style/SymbolArray:
136
+ Description: Using percent style obscures symbolic intent of array's contents.
137
+ Enabled: true
138
+ EnforcedStyle: brackets
139
+
140
+ # Enforce LF line endings, even when on Windows
141
+ Layout/EndOfLine:
142
+ EnforcedStyle: lf
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ os: linux
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.7
7
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in rspec_honeycomb_formatter.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop'
11
+ gem 'rubocop-rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec_honeycomb_formatter (0.1.0)
5
+ honeycomb-beeline
6
+ rspec-core (~> 3.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.0)
14
+ diff-lcs (1.3)
15
+ domain_name (0.5.20190701)
16
+ unf (>= 0.0.5, < 1.0.0)
17
+ ffi (1.12.2)
18
+ ffi-compiler (1.0.1)
19
+ ffi (>= 1.0.0)
20
+ rake
21
+ honeycomb-beeline (2.0.0)
22
+ libhoney (~> 1.14, >= 1.14.2)
23
+ http (4.3.0)
24
+ addressable (~> 2.3)
25
+ http-cookie (~> 1.0)
26
+ http-form_data (~> 2.2)
27
+ http-parser (~> 1.2.0)
28
+ http-cookie (1.0.3)
29
+ domain_name (~> 0.5)
30
+ http-form_data (2.3.0)
31
+ http-parser (1.2.1)
32
+ ffi-compiler (>= 1.0, < 2.0)
33
+ jaro_winkler (1.5.4)
34
+ libhoney (1.14.4)
35
+ addressable (~> 2.0)
36
+ http (>= 2.0, < 5.0)
37
+ parallel (1.19.1)
38
+ parser (2.7.0.4)
39
+ ast (~> 2.4.0)
40
+ public_suffix (4.0.3)
41
+ rainbow (3.0.0)
42
+ rake (13.0.1)
43
+ rexml (3.2.4)
44
+ rspec (3.9.0)
45
+ rspec-core (~> 3.9.0)
46
+ rspec-expectations (~> 3.9.0)
47
+ rspec-mocks (~> 3.9.0)
48
+ rspec-core (3.9.1)
49
+ rspec-support (~> 3.9.1)
50
+ rspec-expectations (3.9.1)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.9.0)
53
+ rspec-mocks (3.9.1)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.9.0)
56
+ rspec-support (3.9.2)
57
+ rubocop (0.80.1)
58
+ jaro_winkler (~> 1.5.1)
59
+ parallel (~> 1.10)
60
+ parser (>= 2.7.0.1)
61
+ rainbow (>= 2.2.2, < 4.0)
62
+ rexml
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 1.7)
65
+ rubocop-rspec (1.38.1)
66
+ rubocop (>= 0.68.1)
67
+ ruby-progressbar (1.10.1)
68
+ unf (0.1.4)
69
+ unf_ext
70
+ unf_ext (0.0.7.6)
71
+ unicode-display_width (1.6.1)
72
+
73
+ PLATFORMS
74
+ ruby
75
+
76
+ DEPENDENCIES
77
+ rake (~> 13.0)
78
+ rspec (~> 3.0)
79
+ rspec_honeycomb_formatter!
80
+ rubocop
81
+ rubocop-rspec
82
+
83
+ BUNDLED WITH
84
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # RSpecHoneycombFormatter
2
+
3
+ This is a simple RSpec formatter that will send all events to the https://honeycomb.io dataset configured in the environment.
4
+ See [honeycombio/beeline-ruby#master lib/honeycomb/configuration.rb](https://github.com/honeycombio/beeline-ruby/blob/master/lib/honeycomb/configuration.rb) for the settings you can use.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'rspec_honeycomb_formatter'
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Add this line to your .rspec file, or add similar configuration to your RSpec rake task:
17
+
18
+ ```
19
+ --require rspec_honeycomb_formatter
20
+ --format RSpecHoneycombFormatter
21
+ ```
22
+
23
+ Running your spec tests will now send output to honeycomb.
24
+
25
+
26
+ ## Development
27
+
28
+ To install this gem onto your local machine, run `bundle exec rake install`.
29
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/puppetlabs/rspec_honeycomb_formatter.
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.options = %w[-D -S -E]
11
+ end
12
+
13
+ task default: [:rubocop, :spec]
data/appveyor.yml ADDED
@@ -0,0 +1,24 @@
1
+ ---
2
+ install:
3
+ - set PATH=C:\Ruby25-x64\bin;%PATH%
4
+ - gem install bundler -v 2.1.4
5
+ - bundle -v
6
+ - bundle install --retry 2
7
+
8
+ build: off
9
+
10
+ branches:
11
+ only:
12
+ - master
13
+
14
+ before_test:
15
+ - bundle env
16
+ - type Gemfile.lock
17
+
18
+ test_script:
19
+ - bundle exec rake
20
+
21
+ # Uncomment this block to enable RDP access to the AppVeyor test instance for
22
+ # debugging purposes.
23
+ # on_finish:
24
+ # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec_honeycomb_formatter/version'
4
+ require 'rspec/core/formatters'
5
+ require 'honeycomb-beeline'
6
+
7
+ Honeycomb.configure do |config|
8
+ end
9
+ process_span = Honeycomb.start_span(name: File.basename($PROGRAM_NAME))
10
+ process_span.add_field('process.full_name', $PROGRAM_NAME)
11
+ process_span.add_field('process.args', ARGV)
12
+ at_exit do
13
+ if $ERROR_INFO&.is_a?(SystemExit)
14
+ process_span.add_field('process.exit_code', $ERROR_INFO.status)
15
+ elsif $ERROR_INFO
16
+ process_span.add_field('process.exit_code', $ERROR_INFO.class.name)
17
+ else
18
+ process_span.add_field('process.exit_code', 'unknown')
19
+ end
20
+ process_span.send
21
+ end
22
+
23
+ # A custom formatter for RSpec that posts messages to https://honeycomb.io for analysis
24
+ class RSpecHoneycombFormatter
25
+ ::RSpec::Core::Formatters.register self, :start,
26
+ :example_group_started, :example_group_finished,
27
+ :example_started, :example_passed, :example_failed, :example_pending, :message,
28
+ :stop, :start_dump, :seed
29
+
30
+ def initialize(_output)
31
+ @group_stack = []
32
+ end
33
+
34
+ def start(notification)
35
+ @start_span = Honeycomb.start_span(name: 'rspec')
36
+ @start_span.add_field('rspec.example_count', notification.count)
37
+ @start_span.add_field('rspec.load_time_ms', notification.load_time * 1000)
38
+ end
39
+
40
+ def stop(notification)
41
+ @start_span.add_field('rspec.failed_count', notification.failed_examples.size)
42
+ @start_span.add_field('rspec.pending_count', notification.pending_examples.size)
43
+ @start_span.send
44
+ end
45
+
46
+ def start_dump(notification)
47
+ # puts "start_dump: #{notification}"
48
+ end
49
+
50
+ def example_group_started(notification)
51
+ @group_stack.push(group_span = Honeycomb.start_span(name: notification.group.description))
52
+ group_span.add_field('rspec.type', 'group')
53
+ group_span.add_field('rspec.file_path', notification.group.file_path)
54
+ group_span.add_field('rspec.location', notification.group.location)
55
+ end
56
+
57
+ def example_group_finished(_notification)
58
+ group_span = @group_stack.pop
59
+ group_span.send
60
+ end
61
+
62
+ def example_started(notification)
63
+ @example_span = Honeycomb.start_span(name: 'unknown')
64
+ @example_span.add_field('rspec.type', 'example')
65
+ @example_span.add_field('rspec.file_path', notification.example.file_path)
66
+ @example_span.add_field('rspec.location', notification.example.location)
67
+ end
68
+
69
+ def example_passed(notification)
70
+ @example_span.add_field('rspec.result', 'passed')
71
+ @example_span.add_field('name', notification.example.description)
72
+ @example_span.add_field('rspec.description', notification.example.description)
73
+ @example_span.send
74
+ end
75
+
76
+ def example_failed(notification)
77
+ @example_span.add_field('rspec.result', 'failed')
78
+ @example_span.add_field('name', notification.example.description)
79
+ @example_span.add_field('rspec.description', notification.example.description)
80
+ @example_span.add_field('rspec.message', strip_ansi(notification.message_lines.join("\n")))
81
+ @example_span.add_field('rspec.backtrace', notification.formatted_backtrace.join("\n"))
82
+ @example_span.send
83
+ end
84
+
85
+ def example_pending(notification)
86
+ @example_span.add_field('rspec.result', 'pending')
87
+ @example_span.add_field('name', notification.example.description)
88
+ @example_span.add_field('rspec.description', notification.example.description)
89
+ @example_span.add_field('rspec.message', strip_ansi(notification.message_lines.join("\n")))
90
+ @example_span.add_field('rspec.backtrace', notification.formatted_backtrace.join("\n"))
91
+ @example_span.send
92
+ end
93
+
94
+ def seed(notification)
95
+ @start_span.add_field('rspec.seed', notification.seed) if notification.seed_used?
96
+ end
97
+
98
+ def message(notification)
99
+ puts "message: #{notification}"
100
+ end
101
+
102
+ private
103
+
104
+ def strip_ansi(string)
105
+ string.gsub(%r{\e\[([\d;]+)m}, '')
106
+ end
107
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RSpecHoneycombFormatter
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/rspec_honeycomb_formatter/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'rspec_honeycomb_formatter'
7
+ spec.version = RSpecHoneycombFormatter::VERSION
8
+ spec.authors = ['David Schmitt', 'Team IAC']
9
+ spec.email = ['david.schmitt@puppet.com', 'https://puppetlabs.github.io/iac/']
10
+
11
+ spec.summary = 'A custom RSpec formatter for https://honeycomb.io'
12
+ spec.homepage = 'https://github.com/puppetlabs/rspec_honeycomb_formatter'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'https://github.com/puppetlabs/rspec_honeycomb_formatter'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/puppetlabs/rspec_honeycomb_formatter/blob/master/CHANGELOG.md'
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_runtime_dependency 'honeycomb-beeline'
29
+ spec.add_runtime_dependency 'rspec-core', '~> 3.0'
30
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec_honeycomb_formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Schmitt
8
+ - Team IAC
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2020-03-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: honeycomb-beeline
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec-core
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.0'
42
+ description:
43
+ email:
44
+ - david.schmitt@puppet.com
45
+ - https://puppetlabs.github.io/iac/
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".github/CODEOWNERS"
51
+ - ".gitignore"
52
+ - ".rspec"
53
+ - ".rubocop.yml"
54
+ - ".travis.yml"
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - appveyor.yml
61
+ - lib/rspec_honeycomb_formatter.rb
62
+ - lib/rspec_honeycomb_formatter/version.rb
63
+ - rspec_honeycomb_formatter.gemspec
64
+ homepage: https://github.com/puppetlabs/rspec_honeycomb_formatter
65
+ licenses: []
66
+ metadata:
67
+ homepage_uri: https://github.com/puppetlabs/rspec_honeycomb_formatter
68
+ source_code_uri: https://github.com/puppetlabs/rspec_honeycomb_formatter
69
+ changelog_uri: https://github.com/puppetlabs/rspec_honeycomb_formatter/blob/master/CHANGELOG.md
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 2.3.0
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.7.6.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: A custom RSpec formatter for https://honeycomb.io
90
+ test_files: []