rack-heartbeat 1.0 → 1.0.1

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: 5c261a1f6516f728668ff8136fd85c9e91d7d6fb
4
- data.tar.gz: e12b517089b96726fe3c43464144783d43a530af
3
+ metadata.gz: 2f91474fa924440ab0c9072b3636ffa7225b28cc
4
+ data.tar.gz: b864ec021073c6c39fb1e84deea53378a3b760b5
5
5
  SHA512:
6
- metadata.gz: 469a5024bff29ae68aeeb94860dc0338f1b23978dffafbc5166b8c27aa5cc88e1833f1b1aca26eff3896e67debed4f73a47f9dec5c35958d1ebe136b3b3b6a25
7
- data.tar.gz: a7c74d79116fdd3e0c5b9bd6cd0321640f35a0bf688893cabc7810c449532d88a2258bde02fbd80d17531bce5d159f7b3c0d9f16b3a787c6880a3a78d34e4877
6
+ metadata.gz: 043d03774af1f1b4b4dc79a433da8030501d840e9557d7aa9fe59f1987f05e72caf4d4d7a9cfff2f1ac39d35e65d8221dc5f03c7ca2079cc3cac1abbaccfc89e
7
+ data.tar.gz: 7603c6b7c54a80220c9e44d58b531bcb8946c6a39fdd7aca86bd055b925c616a75898dcbabadb5fd7ccb527dfc28aa9a84bc6b5ea0f0e05264fe1706ceba6ede
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in rack-heartbeat.gemspec
4
3
  gemspec
4
+
5
+ gem 'coveralls', :group => :test, :require => false
data/README.md CHANGED
@@ -23,7 +23,7 @@ Once the gem is installed, you're done. Just browse to localhost:300/heartbeat
23
23
  If you want to customize the url for any reason, you can configure that, too:
24
24
 
25
25
  ```ruby
26
- #config/initilializers/rack_heartbeat.rb
26
+ #config/initializers/rack_heartbeat.rb
27
27
  Rack::Heartbeat.setup do |config|
28
28
  config.heartbeat_path = 'health-check.txt'
29
29
  end
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'test'
7
+ t.test_files = FileList['test/**/test*.rb']
8
+ t.verbose = true
9
+ end
@@ -3,9 +3,18 @@ module Rack
3
3
  # that returns status 200 and content OK when executed.
4
4
 
5
5
  class Heartbeat
6
- cattr_accessor :heartbeat_path
7
6
  @@heartbeat_path = 'heartbeat'
8
-
7
+
8
+ class << self
9
+ def heartbeat_path
10
+ @@heartbeat_path
11
+ end
12
+
13
+ def heartbeat_path=(path)
14
+ @@heartbeat_path = path
15
+ end
16
+ end
17
+
9
18
  def initialize(app)
10
19
  @app = app
11
20
  end
@@ -19,6 +28,10 @@ module Rack
19
28
  end
20
29
  end
21
30
 
31
+ def heartbeat_path
32
+ self.class.heartbeat_path
33
+ end
34
+
22
35
  def self.setup
23
36
  yield self
24
37
  end
@@ -1,5 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
- #require 'rack'
3
2
 
4
3
  Gem::Specification.new do |gem|
5
4
  gem.authors = ["James Cox"]
@@ -13,8 +12,9 @@ Gem::Specification.new do |gem|
13
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
13
  gem.name = "rack-heartbeat"
15
14
  gem.require_paths = ["lib"]
16
- gem.version = '1.0'
15
+ gem.version = '1.0.1'
17
16
 
18
- # deps
19
- gem.add_dependency('rack')
17
+ gem.add_development_dependency('minitest')
18
+ gem.add_development_dependency('rack-test')
19
+ gem.add_runtime_dependency('rack')
20
20
  end
@@ -0,0 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
4
+ require 'minitest/autorun'
5
+ require 'minitest/pride'
6
+ require 'rack-heartbeat'
@@ -0,0 +1,57 @@
1
+ require 'helper'
2
+
3
+ class Rack::TestHeartbeat < Minitest::Test
4
+ def setup
5
+ @app = Minitest::Mock.new
6
+ @heartbeat = Rack::Heartbeat.new(@app)
7
+ end
8
+
9
+ def teardown
10
+ Rack::Heartbeat.setup do |config|
11
+ config.heartbeat_path = 'heartbeat'
12
+ end
13
+ end
14
+
15
+ def test_initialize_sets_default_heartbeat_path
16
+ assert_match(/\Aheartbeat\z/, @heartbeat.heartbeat_path)
17
+ end
18
+
19
+ def test_call_when_env_empty_sends_app_call
20
+ env = {}
21
+
22
+ @app.expect :call, nil, [env]
23
+ @heartbeat.call(env)
24
+ @app.verify
25
+ end
26
+
27
+ def test_call_when_path_info_is_nil_sends_app_call
28
+ env = {'PATH_INFO' => nil}
29
+
30
+ @app.expect :call, nil, [env]
31
+ @heartbeat.call(env)
32
+ @app.verify
33
+ end
34
+
35
+ def test_call_when_path_info_does_not_match_heartbeat_sends_app_call
36
+ env = {'PATH_INFO' => 'some-path'}
37
+
38
+ @app.expect :call, nil, [env]
39
+ @heartbeat.call(env)
40
+ @app.verify
41
+ end
42
+
43
+ def test_call_when_path_info_matches_heartbeat_path_returns_200_response
44
+ env = {'PATH_INFO' => '/heartbeat'}
45
+
46
+ assert_equal [200, {'Content-Type' => 'text/plain'}, ['OK']], @heartbeat.call(env)
47
+ end
48
+
49
+ def test_setup_configures_heartbeat_path
50
+ expected = 'health-check.txt'
51
+ Rack::Heartbeat.setup do |config|
52
+ config.heartbeat_path = expected
53
+ end
54
+
55
+ assert_match expected, Rack::Heartbeat.heartbeat_path
56
+ end
57
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-heartbeat
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Cox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rack
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -41,6 +69,8 @@ files:
41
69
  - lib/rack/heartbeat.rb
42
70
  - lib/rack/heartbeat/railtie.rb
43
71
  - rack-heartbeat.gemspec
72
+ - test/helper.rb
73
+ - test/rack/test_heartbeat.rb
44
74
  homepage: https://github.com/imajes/rack-heartbeat
45
75
  licenses: []
46
76
  metadata: {}
@@ -65,4 +95,6 @@ signing_key:
65
95
  specification_version: 4
66
96
  summary: provides a simple endpoint for your rails app for a heartbeat client to connect
67
97
  to
68
- test_files: []
98
+ test_files:
99
+ - test/helper.rb
100
+ - test/rack/test_heartbeat.rb