rspec-datadog 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWU5YjQ2Y2E1NDM1NjU5ZGM0OTFmZTlmOGE0MGI1M2VlMzgyNWRjZA==
5
+ data.tar.gz: !binary |-
6
+ YjIzY2M4ZDM0NzFhMmI1YmM0OTZjNjI1MWM3MjQxMWRjZGJhNjM1NA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTZmNDg0NTc0MTE4NTkyNWY1OTBlNjlkOTcxMDZhYTUyY2YxZTFiOGE2Yjcz
10
+ MDVhM2QzNGM5ODkzMjQ4MmRjMDgyY2I2NGQzZDgwNjViMDMyYTUxNjdhODVl
11
+ ZTU1MmY0ZmI2N2NjOTk3NjRlMTA0NjZiOTdjMmU1ZjFmMDRlNDY=
12
+ data.tar.gz: !binary |-
13
+ YWJiNjdlMGJkYmE2MmY4ZThlNDg3MzkzMzJiOWUzMGMxZDdjOTQ0YzcxZjRm
14
+ ZDFmNmZhYmUxMGQzMTNkOTQ5OTg4OWY1MjBjYjY0NjRmYzM0YWZkZDA1YzA1
15
+ MDBmOWY4MTc5ZjA2OWVkYmJmMjIzM2NlNTVjMmIyMWI5OTViZGI=
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby
5
+ - 2.2
6
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,52 @@
1
+ Thanks for your interest in the rspec-datadog project. When you make a
2
+ contribution to the project (e.g. any modifications, additions to existing work,
3
+ pull requests or any other work intentionally submitted by you for inclusion in
4
+ the project) (collectively, a "Contribution"), Lookout wants to be able to use
5
+ your Contribution to improve this project and other Lookout products.
6
+
7
+ As a condition of providing a Contribution, you agree to the following terms and
8
+ conditions (“Terms”):
9
+
10
+ 1. Copyright License: Subject to these Terms, you grant Lookout and to
11
+ recipients of software distributed by Lookout a perpetual, worldwide,
12
+ non-exclusive, no-charge, royalty-free, irrevocable license to make, use, sell,
13
+ reproduce, modify, distribute (directly and indirectly), and publicly display
14
+ and perform the Contribution, and any derivative works that Lookout may make
15
+ from the Contribution.
16
+
17
+ 2. Patent License: Subject to these Terms, you grant Lookout and to recipients
18
+ of software distributed by Lookout a perpetual, worldwide, non-exclusive,
19
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
20
+ license to make, have made, use, offer to sell, sell, import, or otherwise
21
+ transfer the Contribution, where such license applies only to those patent
22
+ claims licensable by you that are necessarily infringed by your Contribution(s)
23
+ alone or by combination of your Contribution(s) with any works or projects to
24
+ which such Contribution(s) was submitted. If any entity institutes patent
25
+ litigation against you or any other entity (including a cross-claim or
26
+ counterclaim in a lawsuit) alleging that your Contribution(s) or the projects to
27
+ which you have contributed, constitutes direct or contributory patent
28
+ infringement, then any patent licenses granted to that entity under this
29
+ agreement for that Contribution, work or other project shall terminate as of the
30
+ date such litigation is filed.
31
+
32
+ 3. You warrant and represent that the Contribution(s) is your original
33
+ creation, that you have the authority and are legally entitled to grant these
34
+ licenses to Lookout, and that these licenses do not require the permission of
35
+ any third party.
36
+
37
+ 4. Except for the warranties in Section 3, you provide any Contribution(s) on
38
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
39
+ or implied, including, without limitation, any warranties or conditions of
40
+ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
41
+
42
+ 5. You agree to notify Lookout of any facts or circumstances of which you
43
+ become aware of that would make any representations made by you inaccurate in
44
+ any respect.
45
+
46
+ Should you wish to submit a suggestion or work that is not your original
47
+ creation, you may submit it to Lookout separate from any Contribution,
48
+ explicitly identifying it as sourced from a third party, stating the complete
49
+ details of its source, and informing Lookout of any license or other restriction
50
+ (including but not limited to related patents, trademarks, and license
51
+ agreement) of which you are personally aware, and conspicuously marking the work
52
+ as “Submitted on behalf of a third party: [named here].”
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-datadog.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Lookout, Inc
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,55 @@
1
+ # RSpec::Datadog
2
+
3
+ This gem provides a custom rspec formatter that sends events to
4
+ [DataDog](https://www.datadoghq.com/). Events will contain four tags
5
+ ("full\_description:foo", "status:succeeded", "file\_path:foo",
6
+ "line\_number:123") plus any defined in DatadogFormatter::BASE\_TAGS; more
7
+ information about `Datadog::Event` and querying these events can be found in the
8
+ [DataDog API Reference](http://docs.datadoghq.com/api/)
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rspec-datadog'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install rspec-datadog
25
+
26
+ ## Usage
27
+
28
+ Run as follows:
29
+ ```
30
+ DATADOG_API_KEY=foo DATADOG_APPLICATION_KEY=bar bundle exec rspec -r rspec/datadog --format DatadogFormatter spec
31
+ ```
32
+
33
+ Running with `DEBUG=1` will cause it to print output to stdout instead of emitting to DataDog.
34
+
35
+ If you have any tags you want applied to *all* examples, then add this to your
36
+ spec_helper:
37
+ ```
38
+ class DatadogFormatter
39
+ BASE_TAGS = %w(foo)
40
+ end
41
+ ```
42
+
43
+ Note that all examples in a given run will have a UUID aggregation key added.
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at
48
+ https://github.com/lookout/rspec-datadog. Please see the Contributor License
49
+ Agreement in CONTRIBUTING.
50
+
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
55
+
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/datadog"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,56 @@
1
+ require "rspec/datadog/version"
2
+ require 'rspec/core'
3
+ require 'rspec/core/formatters'
4
+ require 'rspec/core/formatters/json_formatter'
5
+ require 'active_support'
6
+
7
+ require 'dogapi'
8
+
9
+ class DatadogFormatter < RSpec::Core::Formatters::JsonFormatter
10
+ BASE_TAGS = [] # Override this to add custom base tags - name of the system under test, for example
11
+
12
+ KEYS_TO_EMIT = [:full_description, :status, :file_path, :line_number].freeze
13
+
14
+ def initialize(output)
15
+ super
16
+
17
+ # Initialize Dogapi client
18
+ @dog = Dogapi::Client.new(ENV['DATADOG_API_KEY'], ENV['DATADOG_APPLICATION_KEY'])
19
+ end
20
+
21
+ def close
22
+ # Set now to a value shared by all events for this test run
23
+ now = Time.now.to_i
24
+
25
+ datadog_events = @output_hash[:examples].map do |example|
26
+ tags = hash_to_tags(
27
+ example.slice(*KEYS_TO_EMIT)
28
+ )
29
+
30
+ Dogapi::Event.new("#{example[:full_description]}: #{example[:status]}",
31
+ :msg_title => "RSpec example",
32
+ :tags => BASE_TAGS + tags,
33
+ :date_happened => now
34
+ )
35
+ end
36
+
37
+ datadog_events.each do |event|
38
+ emit_event(event)
39
+ end
40
+ end
41
+
42
+ private
43
+ def hash_to_tags(example_hash)
44
+ example_hash.map do |k,v|
45
+ "#{k}:#{v}"
46
+ end
47
+ end
48
+
49
+ def emit_event(event)
50
+ if ENV['DEBUG']
51
+ puts JSON.pretty_generate(event.to_hash)
52
+ else
53
+ @dog.emit_event(event)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module Datadog
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/datadog/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-datadog"
8
+ spec.version = RSpec::Datadog::VERSION
9
+ spec.authors = ["Ian Smith"]
10
+ spec.email = ["ian.smith@lookout.com"]
11
+
12
+ spec.summary = %q{A datadog reporter wrapped in an rspec formatter}
13
+ spec.description = %q{A datadog reporter wrapped in an rspec formatter; reports rspec results as datadog events}
14
+ spec.homepage = "https://github.com/lookout/rspec-datadog"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency 'rspec', '~> 2.99'
33
+ spec.add_development_dependency 'pry'
34
+ spec.add_development_dependency 'pry-nav'
35
+
36
+ spec.add_dependency 'rspec-core', '~> 2.99'
37
+ spec.add_dependency 'dogapi'
38
+ spec.add_dependency 'activesupport'
39
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-datadog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ian Smith
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.99'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.99'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-nav
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-core
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '2.99'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.99'
97
+ - !ruby/object:Gem::Dependency
98
+ name: dogapi
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A datadog reporter wrapped in an rspec formatter; reports rspec results
126
+ as datadog events
127
+ email:
128
+ - ian.smith@lookout.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .rspec
135
+ - .travis.yml
136
+ - CONTRIBUTING
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/setup
143
+ - lib/rspec/datadog.rb
144
+ - lib/rspec/datadog/version.rb
145
+ - rspec-datadog.gemspec
146
+ homepage: https://github.com/lookout/rspec-datadog
147
+ licenses:
148
+ - MIT
149
+ metadata:
150
+ allowed_push_host: https://rubygems.org
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.4.5
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: A datadog reporter wrapped in an rspec formatter
171
+ test_files: []