deas-json 0.3.3 → 0.3.4
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 +4 -4
- data/Gemfile +2 -1
- data/deas-json.gemspec +1 -1
- data/lib/deas-json/version.rb +1 -1
- data/lib/deas-json/view_handler.rb +3 -2
- data/test/unit/view_handler_tests.rb +16 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
|
4
|
-
|
3
|
+
metadata.gz: ffb78b97d32a51e70c814c6d4ba88679de271f00e93b013284119e3012332748ffc1375d6c9f5b7a6dee8c787ba1ed8e4b3f2b70d63a6f95b631c83d8e81e736
|
4
|
+
data.tar.gz: 697337237b5f8a0df6af90d68f9b2165289b3ae86557bf082b03255009e3258d88c7836ba5bd250ae9f224344bea322d3373fe7e1fe81569fa9bb26329454041
|
5
5
|
SHA1:
|
6
|
-
|
7
|
-
|
6
|
+
metadata.gz: b86dfc65f0df9f644eca7b0cb7aa489922aec73e
|
7
|
+
data.tar.gz: 6e80493cd90b61b8e4b7c733e66cfdc3d5d6ca54
|
data/Gemfile
CHANGED
data/deas-json.gemspec
CHANGED
data/lib/deas-json/version.rb
CHANGED
@@ -23,12 +23,13 @@ module Deas::Json
|
|
23
23
|
|
24
24
|
# Some http clients will error when trying to parse an empty body when the
|
25
25
|
# content type is 'json'. This will default the body to a string that
|
26
|
-
# can be parsed to an empty json object
|
26
|
+
# can be parsed to an empty json object.
|
27
|
+
# We call the `body` helper method to make sure it adhere's to the Rack spec
|
27
28
|
def halt(*args)
|
28
29
|
super(
|
29
30
|
args.first.instance_of?(::Fixnum) ? args.shift : DEF_STATUS,
|
30
31
|
args.first.kind_of?(::Hash) ? args.shift : DEF_HEADERS,
|
31
|
-
args.first.
|
32
|
+
body(!args.first.to_s.empty? ? args.shift : DEF_BODY)
|
32
33
|
)
|
33
34
|
end
|
34
35
|
|
@@ -57,12 +57,21 @@ module Deas::Json::ViewHandler
|
|
57
57
|
assert_equal @body, response.body
|
58
58
|
end
|
59
59
|
|
60
|
+
should "should adhere to the rack spec for its body" do
|
61
|
+
@handler.halt_args = [@status, @headers, @body.first]
|
62
|
+
response = @runner.run
|
63
|
+
|
64
|
+
assert_equal @status, response.status
|
65
|
+
assert_equal @headers, response.headers
|
66
|
+
assert_equal @body, response.body
|
67
|
+
end
|
68
|
+
|
60
69
|
should "default its status, headers and body if not provided" do
|
61
70
|
response = @runner.run
|
62
71
|
|
63
72
|
assert_equal DEF_STATUS, response.status
|
64
73
|
assert_equal DEF_HEADERS, response.headers
|
65
|
-
assert_equal DEF_BODY,
|
74
|
+
assert_equal [DEF_BODY], response.body
|
66
75
|
end
|
67
76
|
|
68
77
|
should "default its headers and body if not provided" do
|
@@ -71,7 +80,7 @@ module Deas::Json::ViewHandler
|
|
71
80
|
|
72
81
|
assert_equal @status, response.status
|
73
82
|
assert_equal DEF_HEADERS, response.headers
|
74
|
-
assert_equal DEF_BODY,
|
83
|
+
assert_equal [DEF_BODY], response.body
|
75
84
|
end
|
76
85
|
|
77
86
|
should "default its status and body if not provided" do
|
@@ -80,7 +89,7 @@ module Deas::Json::ViewHandler
|
|
80
89
|
|
81
90
|
assert_equal DEF_STATUS, response.status
|
82
91
|
assert_equal @headers, response.headers
|
83
|
-
assert_equal DEF_BODY,
|
92
|
+
assert_equal [DEF_BODY], response.body
|
84
93
|
end
|
85
94
|
|
86
95
|
should "default its status and headers if not provided" do
|
@@ -111,12 +120,12 @@ module Deas::Json::ViewHandler
|
|
111
120
|
end
|
112
121
|
|
113
122
|
should "default its body if not provided" do
|
114
|
-
@handler.halt_args = [@status, @headers]
|
123
|
+
@handler.halt_args = [@status, @headers, [nil, ''].sample]
|
115
124
|
response = @runner.run
|
116
125
|
|
117
|
-
assert_equal @status,
|
118
|
-
assert_equal @headers,
|
119
|
-
assert_equal DEF_BODY, response.body
|
126
|
+
assert_equal @status, response.status
|
127
|
+
assert_equal @headers, response.headers
|
128
|
+
assert_equal [DEF_BODY], response.body
|
120
129
|
end
|
121
130
|
|
122
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deas-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2018-04-18 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: assert
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.43.
|
32
|
+
version: 0.43.4
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id002
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
requirements: []
|
89
89
|
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.6.
|
91
|
+
rubygems_version: 2.6.6
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: JSON helpers for Deas apps
|