rapporteur 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18491d6668aca4eab9adff7243c0ec9368453052
4
- data.tar.gz: 9e11081bda92072f1121f7d681feb89cb4e8558f
3
+ metadata.gz: 740374b415d28c691af4809b890ea97cc8123608
4
+ data.tar.gz: 4807f028b631e7eeb3140164ac6568a61743f731
5
5
  SHA512:
6
- metadata.gz: 377f759129b400cc99c6a6e67b6273d1dcb713b25deae97774bfc3bf01aa4d0709f6916e200f2b57a91c7113826639121afd076066edf954d2657336e4ed2aa7
7
- data.tar.gz: 534a635a0f4c185662135a09ef0996e4e21a62f7834095997e4a291a853570ecd0c9cf6fcae2509b20fdfa6b495db679c5203d1388fe2e3ffc3404719c4976f9
6
+ metadata.gz: 427a910ae0ed9b2f33dfbbb2a3440b96b50c5d5ceb8af606a5eaf66d71001de2da7bd669807624bba663c940f1ac9ed0d87da485d4328c080e657895363acc76
7
+ data.tar.gz: b92fe37f5c3887638cecd112d537208ed258e8d42d920e721ca5500a48552b2312c718d2d945f7c87acd7866fb471a2036386621ac95d8dd2b8d346d02c5957d
data/.travis.yml CHANGED
@@ -1,11 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
4
+ - 2.1.2
6
5
  - jruby-19mode
7
6
  gemfile:
8
- - gemfiles/rails3.1.gemfile
9
7
  - gemfiles/rails3.2.gemfile
10
8
  - gemfiles/rails4.x.gemfile
11
9
  notifications:
data/Appraisals CHANGED
@@ -1,7 +1,3 @@
1
- appraise "rails3.1" do
2
- gem "railties", "~> 3.1.0"
3
- end
4
-
5
1
  appraise "rails3.2" do
6
2
  gem "railties", "~> 3.2.0"
7
3
  end
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  * No significant changes.
6
6
 
7
+ ## [3.1.0][v3.1.0] / 2014-07-03
8
+
9
+ * Remove the explicit railties dependency (was at `'>= 3.1', '< 4.2'`). This
10
+ allows Rapporteur to be used in Sinatra applications without loading
11
+ railties, actionpack, etc.
12
+ * Update the packaged RSpec matchers to allow matching against regular
13
+ expressions or strings.
14
+ * Add support for deprecation-less RSpec 3 by introducing rapporteur/rspec3.
15
+ * Removed official support for Rails 3.1.x, as it is no longer supported by the
16
+ Rails core team.
17
+
7
18
  ## [3.0.2][v3.0.2] / 2014-05-17
8
19
 
9
20
  * Test for and allow compatibility with railties 4.1.
@@ -81,7 +92,8 @@
81
92
  * Initial public release.
82
93
 
83
94
 
84
- [unreleased]: https://github.com/codeschool/rapporteur/compare/v3.0.2...master
95
+ [unreleased]: https://github.com/codeschool/rapporteur/compare/v3.1.0...master
96
+ [v3.1.0]: https://github.com/codeschool/rapporteur/compare/v3.0.2...v3.1.0
85
97
  [v3.0.2]: https://github.com/codeschool/rapporteur/compare/v3.0.1...v3.0.2
86
98
  [v3.0.1]: https://github.com/codeschool/rapporteur/compare/v3.0.0...v3.0.1
87
99
  [v3.0.0]: https://github.com/codeschool/rapporteur/compare/v2.1.0...v3.0.0
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Rapporteur (rap-or-TUHR)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/rapporteur.png)](http://badge.fury.io/rb/rapporteur)
4
- [![Build Status](https://travis-ci.org/codeschool/rapporteur.png?branch=master)](https://travis-ci.org/codeschool/rapporteur)
5
- [![Code Climate](https://codeclimate.com/github/codeschool/rapporteur.png)](https://codeclimate.com/github/codeschool/rapporteur)
3
+ [![Gem Version](http://img.shields.io/gem/v/rapporteur.svg)](http://rubygems.org/gems/rapporteur)
4
+ [![Build Status](http://img.shields.io/travis/codeschool/rapporteur/master.svg)](https://travis-ci.org/codeschool/rapporteur)
5
+ [![Code Climate](http://img.shields.io/codeclimate/github/codeschool/rapporteur.svg)](https://codeclimate.com/github/codeschool/rapporteur)
6
+ [![Dependency Status](https://gemnasium.com/codeschool/rapporteur.svg)](https://gemnasium.com/codeschool/rapporteur)
7
+
6
8
 
7
9
  This gem provides a singular, status-checking endpoint to your application. The
8
10
  endpoint provides a JSON response with either an HTTP 200 or an HTTP 500
@@ -48,7 +50,7 @@ $ bundle install
48
50
 
49
51
  Supported Ruby versions:
50
52
 
51
- * MRI 2.1.0
53
+ * MRI 2.1
52
54
  * MRI 2.0.0
53
55
  * MRI 1.9.3
54
56
  * MRI 1.9.2
@@ -59,14 +61,11 @@ Supported Rails versions:
59
61
  * Rails 4.1.x.
60
62
  * Rails 4.0.x.
61
63
  * Rails 3.2.x.
62
- * Rails 3.1.x.
63
64
 
64
- ## Usage
65
+ Non-Rails environments are also supported (such as Sinatra), see Usage below
66
+ for details.
65
67
 
66
- Simply adding the gem requirement to your Gemfile is enough to install and
67
- automatically load and configure the gem. Technically speaking, the gem is a
68
- Rails Engine, so it auto-initializes with Rails starts up. There is no further
69
- configuration necessary.
68
+ ## Usage
70
69
 
71
70
  By default, there are no application checks that run and the status endpoint
72
71
  simply reports the current application revision and time. This is useful for a
@@ -102,6 +101,39 @@ link_to status_path
102
101
  Were you already using the `/status.json` endpoint or the "status" route name?
103
102
  Hmm. Well... you just broke it.
104
103
 
104
+ ### Usage without Rails (i.e. Sinatra)
105
+
106
+ If your application does not have Rails loaded, the Rails Engine logic will be
107
+ bypassed. In this case, you must configure and run your Rapporteur reports
108
+ manually because, in the very least, your status route will not be
109
+ automatically generated as previously described.
110
+
111
+ So, here is an example usage in Sinatra:
112
+
113
+ ```ruby
114
+ require 'rapporteur'
115
+ require 'my_app/api/endpoint'
116
+
117
+ module MyApp
118
+ module API
119
+ module Endpoints
120
+ class Status < Endpoint
121
+ get "/status.json" do
122
+ status 200
123
+ json Rapporteur.run.as_json
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ ```
130
+
131
+ Require `rapporteur` and then, at some point, call `Rapporteur.run` to execute
132
+ the configured checks. `as_json` will convert the result of the `run` into a
133
+ Hash which is ready for JSON generation. At that point, do whatever you need to
134
+ do with the Hash to have your framework of choice generate and respond with
135
+ JSON.
136
+
105
137
  ## Customization
106
138
 
107
139
  ### Adding checks
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
- require 'appraisal'
4
5
 
5
6
  RSpec::Core::RakeTask.new(:spec)
6
7
  task :default => :spec
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord-jdbcsqlite3-adapter", :platforms=>:jruby
6
- gem "sqlite3", :platforms=>:ruby
5
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
6
+ gem "sqlite3", :platforms => :ruby
7
7
  gem "railties", "~> 3.2.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord-jdbcsqlite3-adapter", :platforms=>:jruby
6
- gem "sqlite3", :platforms=>:ruby
5
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
6
+ gem "sqlite3", :platforms => :ruby
7
7
  gem "railties", "~> 4.0"
8
8
 
9
- gemspec :path=>"../"
9
+ gemspec :path => "../"
@@ -44,7 +44,7 @@ end
44
44
  RSpec::Matchers.define :include_status_error_message do |attribute, message|
45
45
  match do |response|
46
46
  @body = JSON.parse(response.body)
47
- @body.fetch('errors', {}).fetch(attribute.to_s).include?(message)
47
+ @body.fetch('errors', {}).fetch(attribute.to_s).match(message)
48
48
  end
49
49
 
50
50
  failure_message_for_should do |actual|
@@ -59,7 +59,7 @@ end
59
59
  RSpec::Matchers.define :include_status_message do |name, message|
60
60
  match do |response|
61
61
  @body = JSON.parse(response.body)
62
- @body.has_key?(name) && @body.fetch(name).include?(message)
62
+ @body.has_key?(name) && @body.fetch(name).match(message)
63
63
  end
64
64
 
65
65
  failure_message_for_should do |actual|
@@ -0,0 +1,69 @@
1
+ require 'rapporteur'
2
+
3
+ shared_examples_for 'a successful status response' do
4
+ it 'responds with HTTP 200' do
5
+ expect(subject.response_code).to(eq(200))
6
+ end
7
+
8
+ it 'responds with a JSON content header' do
9
+ expect(subject.content_type).to(eq(Mime::JSON))
10
+ end
11
+
12
+ it 'responds with valid JSON' do
13
+ expect { JSON.parse(subject.body) }.not_to(raise_error)
14
+ end
15
+
16
+ context 'the response payload' do
17
+ subject { get(status_path) ; JSON.parse(response.body) }
18
+
19
+ it 'does not contain errors' do
20
+ expect(subject).not_to(have_key('errors'))
21
+ end
22
+ end
23
+ end
24
+
25
+ shared_examples_for 'an erred status response' do
26
+ it 'responds with HTTP 500' do
27
+ expect(subject.response_code).to(eq(500))
28
+ end
29
+
30
+ it 'responds with a JSON content header' do
31
+ expect(subject.content_type).to(eq(Mime::JSON))
32
+ end
33
+
34
+ it 'responds with valid JSON' do
35
+ expect { JSON.parse(subject.body) }.not_to(raise_error)
36
+ end
37
+
38
+ it 'contains errors' do
39
+ expect(JSON.parse(subject.body)).to(have_key('errors'))
40
+ expect(JSON.parse(subject.body).fetch('errors')).not_to(be_empty)
41
+ end
42
+ end
43
+
44
+ RSpec::Matchers.define :include_status_error_message do |attribute, message|
45
+ match do |response|
46
+ @body = JSON.parse(response.body)
47
+ @body.fetch('errors', {}).fetch(attribute.to_s).match(message)
48
+ end
49
+
50
+ failure_message_when_negated do |actual|
51
+ "expected #{@body.inspect} to not include a #{attribute}:#{message.inspect} error message"
52
+ end
53
+ end
54
+
55
+ RSpec::Matchers.define :include_status_message do |name, message|
56
+ match do |response|
57
+ @body = JSON.parse(response.body)
58
+
59
+ @body.has_key?(name) && @body.fetch(name).match(message)
60
+ end
61
+
62
+ failure_message do |actual|
63
+ "expected #{@body.inspect} to include a #{name.inspect}: #{message.inspect} message"
64
+ end
65
+
66
+ failure_message_when_negated do |actual|
67
+ "expected #{@body.inspect} to not include a #{name.inspect}: #{message.inspect} message"
68
+ end
69
+ end
@@ -1,3 +1,3 @@
1
1
  module Rapporteur
2
- VERSION = "3.0.2"
2
+ VERSION = "3.1.0"
3
3
  end
data/rapporteur.gemspec CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'i18n', '~> 0.6'
22
- spec.add_dependency 'railties', '>= 3.1', '< 4.2'
23
22
 
24
- spec.add_development_dependency "appraisal", "~> 0.5"
23
+ spec.add_development_dependency "appraisal", "~> 1.0"
25
24
  spec.add_development_dependency "bundler", "~> 1.3"
26
25
  spec.add_development_dependency "combustion", "~> 0.5", ">= 0.5.1"
27
- spec.add_development_dependency "rails", ">= 3.1", "< 4.1"
28
- spec.add_development_dependency "rspec-rails", "~> 2.11"
26
+ spec.add_development_dependency "rails", ">= 3.1", "< 4.2"
27
+ spec.add_development_dependency "rspec-rails", "~> 3.0"
28
+ spec.add_development_dependency "rspec-collection_matchers", "~> 1.0"
29
29
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rapporteur::CheckList do
3
+ describe Rapporteur::CheckList, :type => :model do
4
4
  let(:list) { described_class.new }
5
5
 
6
6
  context '#add' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rapporteur::MessageList do
3
+ describe Rapporteur::MessageList, :type => :model do
4
4
  let(:list) { Rapporteur::MessageList.new(:errors) }
5
5
 
6
6
  before { I18n.backend.reload! }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'A status request with an ActiveRecordCheck' do
3
+ describe 'A status request with an ActiveRecordCheck', :type => :request do
4
4
  before do
5
5
  Rapporteur.add_check(Rapporteur::Checks::ActiveRecordCheck)
6
6
  end
@@ -13,7 +13,7 @@ describe 'A status request with an ActiveRecordCheck' do
13
13
 
14
14
  context 'with a failed ActiveRecord connection' do
15
15
  before do
16
- ActiveRecord::Base.connection.stub(:execute).
16
+ allow(ActiveRecord::Base.connection).to receive(:execute).
17
17
  and_raise(ActiveRecord::ConnectionNotEstablished)
18
18
  end
19
19
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'A check calling #halt!' do
3
+ describe 'A check calling #halt!', :type => :request do
4
4
  before do
5
5
  Rapporteur.add_check { |checker| checker.add_message(:one, 1) }
6
6
  Rapporteur.add_check { |checker| checker.add_message(:two, 2).halt! }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'A status request with a check that modifies messages' do
3
+ describe 'A status request with a check that modifies messages', :type => :request do
4
4
  subject { get(status_path) ; response }
5
5
 
6
6
  context 'creating a message with a block' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'A status request with no checks' do
3
+ describe 'A status request with no checks', :type => :request do
4
4
  subject { get(status_path) ; response }
5
5
 
6
6
  it_behaves_like 'a successful status response'
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'A status request with a RevisionCheck' do
3
+ describe 'A status request with a RevisionCheck', :type => :request do
4
4
  before do
5
- Rapporteur::Revision.stub(:current) { 'revisionidentifier' }
5
+ allow(Rapporteur::Revision).to receive(:current).and_return('revisionidentifier')
6
6
  Rapporteur.add_check(Rapporteur::Checks::RevisionCheck)
7
7
  end
8
8
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'A status request with a TimeCheck' do
3
+ describe 'A status request with a TimeCheck', :type => :request do
4
4
  before do
5
5
  Rapporteur.add_check(Rapporteur::Checks::TimeCheck)
6
6
  end
@@ -11,8 +11,8 @@ describe 'A status request with a TimeCheck' do
11
11
 
12
12
  context 'the response payload' do
13
13
  it 'contains the time in ISO8601' do
14
- Time.stub(:now).and_return(Time.gm(2013,8,23))
15
- expect(subject).to include_status_message('time', Time.gm(2013,8,23).iso8601)
14
+ allow(Time).to receive(:now).and_return(Time.gm(2013,8,23))
15
+ expect(subject).to include_status_message('time', /^2013-08-23T00:00:00(?:.000)?Z$/)
16
16
  end
17
17
  end
18
18
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper.rb'
2
2
 
3
- describe "status routes" do
3
+ describe "status routes", :type => :routing do
4
4
  it 'routes /status.json to statuses#show' do
5
5
  expect({ :get => '/status.json'}).to route_to({
6
6
  :action => 'show',
data/spec/spec_helper.rb CHANGED
@@ -6,10 +6,10 @@ ENV["RAILS_ENV"] ||= 'test'
6
6
  Combustion.initialize! :action_controller, :active_record
7
7
 
8
8
  require 'rspec/rails'
9
- require 'rapporteur/rspec'
9
+ require 'rspec/collection_matchers'
10
+ require 'rapporteur/rspec3'
10
11
 
11
12
  RSpec.configure do |config|
12
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
13
  config.run_all_when_everything_filtered = true
14
14
  config.filter_run :focus
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapporteur
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envy Labs
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-17 00:00:00.000000000 Z
12
+ date: 2014-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -25,40 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0.6'
28
- - !ruby/object:Gem::Dependency
29
- name: railties
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '3.1'
35
- - - "<"
36
- - !ruby/object:Gem::Version
37
- version: '4.2'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: '3.1'
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '4.2'
48
28
  - !ruby/object:Gem::Dependency
49
29
  name: appraisal
50
30
  requirement: !ruby/object:Gem::Requirement
51
31
  requirements:
52
32
  - - "~>"
53
33
  - !ruby/object:Gem::Version
54
- version: '0.5'
34
+ version: '1.0'
55
35
  type: :development
56
36
  prerelease: false
57
37
  version_requirements: !ruby/object:Gem::Requirement
58
38
  requirements:
59
39
  - - "~>"
60
40
  - !ruby/object:Gem::Version
61
- version: '0.5'
41
+ version: '1.0'
62
42
  - !ruby/object:Gem::Dependency
63
43
  name: bundler
64
44
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +82,7 @@ dependencies:
102
82
  version: '3.1'
103
83
  - - "<"
104
84
  - !ruby/object:Gem::Version
105
- version: '4.1'
85
+ version: '4.2'
106
86
  type: :development
107
87
  prerelease: false
108
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -112,21 +92,35 @@ dependencies:
112
92
  version: '3.1'
113
93
  - - "<"
114
94
  - !ruby/object:Gem::Version
115
- version: '4.1'
95
+ version: '4.2'
116
96
  - !ruby/object:Gem::Dependency
117
97
  name: rspec-rails
118
98
  requirement: !ruby/object:Gem::Requirement
119
99
  requirements:
120
100
  - - "~>"
121
101
  - !ruby/object:Gem::Version
122
- version: '2.11'
102
+ version: '3.0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-collection_matchers
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.0'
123
117
  type: :development
124
118
  prerelease: false
125
119
  version_requirements: !ruby/object:Gem::Requirement
126
120
  requirements:
127
121
  - - "~>"
128
122
  - !ruby/object:Gem::Version
129
- version: '2.11'
123
+ version: '1.0'
130
124
  description: An engine that provides common status polling endpoint.
131
125
  email:
132
126
  - ''
@@ -147,7 +141,6 @@ files:
147
141
  - config.ru
148
142
  - config/locales/en.yml
149
143
  - config/routes.rb
150
- - gemfiles/rails3.1.gemfile
151
144
  - gemfiles/rails3.2.gemfile
152
145
  - gemfiles/rails4.x.gemfile
153
146
  - lib/rapporteur.rb
@@ -161,6 +154,7 @@ files:
161
154
  - lib/rapporteur/responder.rb
162
155
  - lib/rapporteur/revision.rb
163
156
  - lib/rapporteur/rspec.rb
157
+ - lib/rapporteur/rspec3.rb
164
158
  - lib/rapporteur/version.rb
165
159
  - rapporteur.gemspec
166
160
  - spec/internal/config/database.yml
@@ -198,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
192
  version: '0'
199
193
  requirements: []
200
194
  rubyforge_project:
201
- rubygems_version: 2.2.2
195
+ rubygems_version: 2.3.0
202
196
  signing_key:
203
197
  specification_version: 4
204
198
  summary: An engine that provides common status polling endpoint.
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord-jdbcsqlite3-adapter", :platforms=>:jruby
6
- gem "sqlite3", :platforms=>:ruby
7
- gem "railties", "~> 3.1.0"
8
-
9
- gemspec :path=>"../"