statsd-instrument-rspec 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43ce3873f066781c87998d613937950216ef3fd7
4
+ data.tar.gz: 1c269cb4eb1342c1d566a628cfa6d02517979be6
5
+ SHA512:
6
+ metadata.gz: a590d7da0d387abf3607b1b76350e6294348bf93ed97e2c6f1bb9870473f72a0d519dc68e60952abf0ffac65f2e7891e3874689735331a06add1c2365483b01d
7
+ data.tar.gz: 1720db21798407b3f08e37fe7c8dead815574a0b8cfefd26f5d14a2969474d2443ab59c10599fd6b4eebd4770a3560705a92c11aa4eac271606c28d538fda6a9
@@ -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
+ --require spec_helper
@@ -0,0 +1,17 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+ Exclude:
6
+ - bin/* # autogenerated files
7
+ - vendor/**/* # 3rd party gems
8
+
9
+ Documentation:
10
+ Enabled: false
11
+ LineLength:
12
+ Max: 120
13
+ StringLiterals:
14
+ EnforcedStyle: double_quotes
15
+ Style/RegexpLiteral:
16
+ Exclude:
17
+ - "statsd-instrument-rspec.gemspec" # Bundler defaults
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ rvm:
5
+ - 2.2
6
+ - 2.1
7
+ - 2.0
8
+ before_install: gem update bundler
@@ -0,0 +1,7 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased][unreleased]
6
+ ### Added
7
+ - Add support for testing increments.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in statsd-instrument-rspec.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Blacklane GmbH
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,66 @@
1
+ # statsd-instrument-rspec
2
+
3
+ [![Build Status](https://travis-ci.org/blacklane/statsd-instrument-rspec.svg?branch=master)](https://travis-ci.org/blacklane/statsd-instrument-rspec) [![Coverage Status](https://coveralls.io/repos/blacklane/statsd-instrument-rspec/badge.svg?branch=master)](https://coveralls.io/r/blacklane/statsd-instrument-rspec?branch=master) [![Code Climate](https://codeclimate.com/github/blacklane/statsd-instrument-rspec/badges/gpa.svg)](https://codeclimate.com/github/blacklane/statsd-instrument-rspec) [![Dependency Status](https://gemnasium.com/blacklane/statsd-instrument-rspec.svg)](https://gemnasium.com/blacklane/statsd-instrument-rspec)
4
+
5
+ RSpec 3 matchers for `statsd-instrument`.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "statsd-instrument-rspec"
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install statsd-instrument-rspec
22
+
23
+ ## Usage
24
+
25
+ Configure RSpec and StatsD (e.g. via the `spec_helper.rb`):
26
+
27
+ ```ruby
28
+ require "statsd/instrument/rspec"
29
+
30
+ RSpec.configure do |config|
31
+ config.include Statsd::Instrument::Rspec # Enable StatsD matchers
32
+
33
+ config.before(:suite) do
34
+ StatsD.backend = StatsD::Instrument::Backends::CaptureBackend.new # Use CaptureBackend
35
+ end
36
+
37
+ config.after do
38
+ StatsD.backend.reset # Reset collected metrics after each example
39
+ end
40
+ end
41
+ ```
42
+
43
+ ### Matchers
44
+
45
+ #### Increment
46
+
47
+ ```ruby
48
+ expect { StatsD.increment(:foo) }.to increment_statsd(:foo)
49
+ expect { StatsD.increment(:bar) }.not_to increment_statsd(:foo)
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ Run the tests with `bundle exec rake`.
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/blacklane/statsd-instrument-rspec/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: %i(rubocop spec)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "statsd/instrument/rspec"
5
+
6
+ require "pry"
7
+ Pry.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,35 @@
1
+ require "rspec/expectations"
2
+ require "statsd-instrument"
3
+ require "statsd/instrument/rspec/version"
4
+
5
+ module Statsd
6
+ module Instrument
7
+ module Rspec
8
+ extend RSpec::Matchers::DSL
9
+
10
+ matcher :increment_statsd do |key|
11
+ match do |block|
12
+ block.call
13
+ metric_captured?(:c, key)
14
+ end
15
+
16
+ failure_message do |_block|
17
+ "Expected that block would increase StatsD metric '#{key}'."
18
+ end
19
+
20
+ failure_message_when_negated do |_block|
21
+ "Expected that block would not increase StatsD metric '#{key}'."
22
+ end
23
+
24
+ def supports_block_expectations?
25
+ true
26
+ end
27
+ end
28
+
29
+ def metric_captured?(type, key)
30
+ metrics = StatsD.backend.collected_metrics
31
+ metrics.any? { |metric| metric.type == type && metric.name == key }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ module Statsd
2
+ module Instrument
3
+ module Rspec
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "statsd/instrument/rspec/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "statsd-instrument-rspec"
8
+ spec.version = Statsd::Instrument::Rspec::VERSION
9
+ spec.authors = ["Philipp Preß"]
10
+ spec.email = ["philipp.press@blacklane.com"]
11
+
12
+ spec.summary = "RSpec 3 matchers for statsd-instrument."
13
+ spec.homepage = "https://github.com/blacklane/statsd-instrument-rspec"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.require_paths = ["lib"]
17
+ spec.required_ruby_version = ">= 2.0"
18
+
19
+ spec.add_runtime_dependency "rspec", "~> 3.0"
20
+ spec.add_runtime_dependency "statsd-instrument", "~> 2.0"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "coveralls", "~> 0.7"
24
+ spec.add_development_dependency "pry", "~> 0.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rubocop", "~> 0.29"
27
+ spec.add_development_dependency "rubocop-rspec", "~> 1.0"
28
+ spec.add_development_dependency "simplecov", "~> 0.9"
29
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: statsd-instrument-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Philipp Preß
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: statsd-instrument
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.29'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.29'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.9'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.9'
139
+ description:
140
+ email:
141
+ - philipp.press@blacklane.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rubocop.yml"
149
+ - ".travis.yml"
150
+ - CHANGELOG.md
151
+ - Gemfile
152
+ - LICENSE
153
+ - README.md
154
+ - Rakefile
155
+ - bin/console
156
+ - bin/setup
157
+ - lib/statsd/instrument/rspec.rb
158
+ - lib/statsd/instrument/rspec/version.rb
159
+ - statsd-instrument-rspec.gemspec
160
+ homepage: https://github.com/blacklane/statsd-instrument-rspec
161
+ licenses: []
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '2.0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.4.5
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: RSpec 3 matchers for statsd-instrument.
183
+ test_files: []