is_it_up 0.0.1 → 0.0.2
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 +8 -8
- data/is_it_up.gemspec +1 -0
- data/lib/is_it_up/middleware.rb +6 -2
- data/lib/is_it_up/version.rb +1 -1
- data/test/cases/middleware_test.rb +30 -8
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDM2YTJhZWQ3YTc2NjYzNzlhOGQ1MDVjY2JhYzY4Zjk5ZWQxOTA1NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjIwODU3YzBlNGViMjNkZWZjNTcwYjA1NTljOTMwNmRlMzQ1ZDlhOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjA3Y2EyOGYwZGViMWU5ZmQ3ZjY2ZTA0YzY3ZTg1MjZiN2FlNzJlOTVjNmU3
|
10
|
+
M2M4MTI4ODI2OWIxOTkyMjQxMmVmNTNmMjdmZTA0NjFmZTNjMmU2OGI0Y2Q4
|
11
|
+
NTA0YzI3ZDg5NTQ1YWIxMWJkM2FhOTgyYjQ5N2RkMDhjYjA0ZjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2Y0MGEzNTlkYmIzOGMyNDhmNzA1OWM0ZTI2NzVkY2U4MTMxMDMxMDM0Mjhh
|
14
|
+
NGYwYTNiMTZiMDBiNzJlYmQzMjU4MzVlYjNiNDdjMGNkNjdlMWYyNzk4ZTU4
|
15
|
+
NTA0Njg1MzRmNmIzNjM5MzY5MDdhZTdhY2VjYTExZTg0ZGMwZGE=
|
data/is_it_up.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "rack"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "json"
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.5"
|
24
25
|
spec.add_development_dependency "minitest", "~> 5.0"
|
25
26
|
end
|
data/lib/is_it_up/middleware.rb
CHANGED
@@ -8,8 +8,12 @@ module IsItUp
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
status, header, response =
|
11
|
-
if env[
|
12
|
-
[
|
11
|
+
if env["PATH_INFO"] == "/is_it_up"
|
12
|
+
[
|
13
|
+
200,
|
14
|
+
{ "Content-Type" => "application/json" },
|
15
|
+
['{ "status": "ok", "code": 200 }']
|
16
|
+
]
|
13
17
|
else
|
14
18
|
@app.call(env)
|
15
19
|
end
|
data/lib/is_it_up/version.rb
CHANGED
@@ -1,27 +1,49 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module IsItUp
|
4
5
|
class MiddlewareTest < TestCase
|
5
6
|
|
6
7
|
let(:rack_app) do
|
7
|
-
@app =
|
8
8
|
Rack::Builder.new do
|
9
9
|
use IsItUp::Middleware
|
10
|
-
run lambda {|env|
|
10
|
+
run lambda { |env|
|
11
|
+
[
|
12
|
+
200,
|
13
|
+
{ "Content-type" => "text/html" },
|
14
|
+
[ "A normal response" ]
|
15
|
+
]
|
16
|
+
}
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
20
|
describe "When the request path contains '/is_it_up'" do
|
15
|
-
|
16
|
-
response = Rack::MockRequest.new(rack_app).get("/is_it_up")
|
17
|
-
|
21
|
+
before do
|
22
|
+
@response = Rack::MockRequest.new(rack_app).get("/is_it_up")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "must respond with a JSON content type'" do
|
26
|
+
@response.content_type.must_equal "application/json"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "must render a JSON response indicating success'" do
|
30
|
+
json = JSON.parse(@response.body)
|
31
|
+
json["status"].must_equal("ok")
|
32
|
+
json["code"].must_equal(200)
|
18
33
|
end
|
19
34
|
end
|
20
35
|
|
21
36
|
describe "When the request path does not contain '/is_it_up'" do
|
22
|
-
|
23
|
-
response = Rack::MockRequest.new(rack_app).get("/not_is_it_up")
|
24
|
-
|
37
|
+
before do
|
38
|
+
@response = Rack::MockRequest.new(rack_app).get("/not_is_it_up")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "must not render the JSON content type" do
|
42
|
+
@response.content_type.must_equal "text/html"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "must not render the JSON response for /is_it_up" do
|
46
|
+
@response.body.must_equal "A normal response"
|
25
47
|
end
|
26
48
|
end
|
27
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_it_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher R. Murphy
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|