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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODNmYjA1NjgzMjllY2RmNjU1Mzc1ZjRkY2RiOGNmNDEzYThhMjA2MA==
4
+ ZDM2YTJhZWQ3YTc2NjYzNzlhOGQ1MDVjY2JhYzY4Zjk5ZWQxOTA1NA==
5
5
  data.tar.gz: !binary |-
6
- Mjc2YWJlZDdkNWU5YjNhYmUyYmQwMmQ5ODVlNGZkZTVkM2U5Njc4MQ==
6
+ YjIwODU3YzBlNGViMjNkZWZjNTcwYjA1NTljOTMwNmRlMzQ1ZDlhOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjJhOTUxNDcwMTBlOWUyMTU2Zjk2M2U3OTdmYzY4MGM1NjUzNmY5MTA1MTZl
10
- ZTk0ZDU4NGVjY2FmZmNhMjhmMThjZGY3ZTdlZTRjMTFiY2VkOTJiYjkwMjcw
11
- OTYzYjU3NjZmOGU5ZWI1YjYwYTZmOWZkODFmNzQ1ZmMxM2NmYjM=
9
+ MjA3Y2EyOGYwZGViMWU5ZmQ3ZjY2ZTA0YzY3ZTg1MjZiN2FlNzJlOTVjNmU3
10
+ M2M4MTI4ODI2OWIxOTkyMjQxMmVmNTNmMjdmZTA0NjFmZTNjMmU2OGI0Y2Q4
11
+ NTA0YzI3ZDg5NTQ1YWIxMWJkM2FhOTgyYjQ5N2RkMDhjYjA0ZjA=
12
12
  data.tar.gz: !binary |-
13
- ZmZmMWQyYTY4ZTRjMDEwMTFjNzdhZjJiMGIyMWVjOTQwZjMzMTQyYjJiN2E0
14
- NjA1MDEwYmE5ZWJmY2ZiNmE3ZDcxODRiNmU0ZGIxN2VhMDQ0OGZiM2QxNDZj
15
- ZWU3MDU0OWRiMjc2NTg0ODQxYWMwOTkxOGQwNTc4MTc0N2JjMDk=
13
+ M2Y0MGEzNTlkYmIzOGMyNDhmNzA1OWM0ZTI2NzVkY2U4MTMxMDMxMDM0Mjhh
14
+ NGYwYTNiMTZiMDBiNzJlYmQzMjU4MzVlYjNiNDdjMGNkNjdlMWYyNzk4ZTU4
15
+ NTA0Njg1MzRmNmIzNjM5MzY5MDdhZTdhY2VjYTExZTg0ZGMwZGE=
@@ -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
@@ -8,8 +8,12 @@ module IsItUp
8
8
 
9
9
  def call(env)
10
10
  status, header, response =
11
- if env['PATH_INFO'] == "/is_it_up"
12
- [200, { "Content-Type" => "text/plain" }, ["It is up."]]
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
@@ -1,3 +1,3 @@
1
1
  module IsItUp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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| [200, {"Content-type" => "text/html"}, ["A response"]] }
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
- it "must render 'It is up.'" do
16
- response = Rack::MockRequest.new(rack_app).get("/is_it_up")
17
- response.body.must_equal "It is up."
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
- it "must not render 'It is up.'" do
23
- response = Rack::MockRequest.new(rack_app).get("/not_is_it_up")
24
- response.body.must_equal "A response"
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.1
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