rasti-web 0.0.2 → 0.0.3
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/lib/rasti/web/render.rb +6 -6
- data/lib/rasti/web/version.rb +1 -1
- data/spec/application_spec.rb +2 -2
- data/spec/controller_spec.rb +1 -1
- data/spec/endpoint_spec.rb +1 -1
- data/spec/render_spec.rb +23 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2ed7458b25215ed07dd7355f1a9dc43ce98d16
|
4
|
+
data.tar.gz: df11d78ed700d06e98a565ac6671f90aeb8208ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e33136ea36d5edcd6d2179fd08c03368e218bf42fba6001d18b579fa7b7ffcbb9a40a823a12cba311994232a4472156d62cb738716438e5d48b664121aa9b6
|
7
|
+
data.tar.gz: 063a8972aa3439a801ade3ff9843f4e247622528d36a8fb477737a73e655e4b5f7f58acd817b4a63230e94501e5c76b5182e1f584e46348e91662ae3f570e9a2
|
data/lib/rasti/web/render.rb
CHANGED
@@ -18,25 +18,25 @@ module Rasti
|
|
18
18
|
|
19
19
|
def text(text, *args)
|
20
20
|
respond_with extract_status(args),
|
21
|
-
extract_headers(args).merge('Content-Type' => 'text/plain'),
|
21
|
+
extract_headers(args).merge('Content-Type' => 'text/plain; charset=utf-8'),
|
22
22
|
text
|
23
23
|
end
|
24
24
|
|
25
25
|
def html(html, *args)
|
26
26
|
respond_with extract_status(args),
|
27
|
-
extract_headers(args).merge('Content-Type' => 'text/html'),
|
27
|
+
extract_headers(args).merge('Content-Type' => 'text/html; charset=utf-8'),
|
28
28
|
html
|
29
29
|
end
|
30
30
|
|
31
31
|
def json(object, *args)
|
32
32
|
respond_with extract_status(args),
|
33
|
-
extract_headers(args).merge('Content-Type' => 'application/json'),
|
33
|
+
extract_headers(args).merge('Content-Type' => 'application/json; charset=utf-8'),
|
34
34
|
object.is_a?(String) ? object : JSON.dump(object)
|
35
35
|
end
|
36
36
|
|
37
37
|
def js(script, *args)
|
38
38
|
respond_with extract_status(args),
|
39
|
-
extract_headers(args).merge('Content-Type' => 'application/javascript'),
|
39
|
+
extract_headers(args).merge('Content-Type' => 'application/javascript; charset=utf-8'),
|
40
40
|
script
|
41
41
|
end
|
42
42
|
|
@@ -50,7 +50,7 @@ module Rasti
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def partial(template, locals={})
|
53
|
-
response['Content-Type'] = 'text/html'
|
53
|
+
response['Content-Type'] = 'text/html; charset=utf-8'
|
54
54
|
response.write view_context.render(template, locals)
|
55
55
|
end
|
56
56
|
|
@@ -58,7 +58,7 @@ module Rasti
|
|
58
58
|
content = block.call if block
|
59
59
|
layout = view_context.render(template || Web.default_layout) { content }
|
60
60
|
|
61
|
-
response['Content-Type'] = 'text/html'
|
61
|
+
response['Content-Type'] = 'text/html; charset=utf-8'
|
62
62
|
response.write layout
|
63
63
|
end
|
64
64
|
|
data/lib/rasti/web/version.rb
CHANGED
data/spec/application_spec.rb
CHANGED
@@ -48,7 +48,7 @@ describe Rasti::Web::Application do
|
|
48
48
|
get '/'
|
49
49
|
|
50
50
|
last_response.status.must_equal 200
|
51
|
-
last_response['Content-Type'].must_equal 'text/html'
|
51
|
+
last_response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
52
52
|
last_response.body.must_equal 'Page content'
|
53
53
|
end
|
54
54
|
|
@@ -70,7 +70,7 @@ describe Rasti::Web::Application do
|
|
70
70
|
get '/api/resource/123'
|
71
71
|
|
72
72
|
last_response.status.must_equal 200
|
73
|
-
last_response['Content-Type'].must_equal 'application/json'
|
73
|
+
last_response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
74
74
|
last_response.body.must_equal '{"id":123}'
|
75
75
|
end
|
76
76
|
|
data/spec/controller_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Rasti::Web::Controller do
|
|
29
29
|
|
30
30
|
action.must_be_instance_of Rasti::Web::Endpoint
|
31
31
|
status.must_equal 200
|
32
|
-
headers['Content-Type'].must_equal 'text/html'
|
32
|
+
headers['Content-Type'].must_equal 'text/html; charset=utf-8'
|
33
33
|
response.body.must_equal ['Test HTML']
|
34
34
|
end
|
35
35
|
|
data/spec/endpoint_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe Rasti::Web::Endpoint do
|
|
15
15
|
status, headers, response = endpoint.call env
|
16
16
|
|
17
17
|
status.must_equal 200
|
18
|
-
headers['Content-Type'].must_equal 'text/plain'
|
18
|
+
headers['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
19
19
|
response.body.must_equal ['Content']
|
20
20
|
end
|
21
21
|
|
data/spec/render_spec.rb
CHANGED
@@ -48,7 +48,7 @@ describe Rasti::Web::Render do
|
|
48
48
|
render.text 'Plain text'
|
49
49
|
|
50
50
|
response.status.must_equal 200
|
51
|
-
response['Content-Type'].must_equal 'text/plain'
|
51
|
+
response['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
52
52
|
response.body.must_equal ['Plain text']
|
53
53
|
end
|
54
54
|
|
@@ -56,7 +56,7 @@ describe Rasti::Web::Render do
|
|
56
56
|
render.text 'Internal server error', 500
|
57
57
|
|
58
58
|
response.status.must_equal 500
|
59
|
-
response['Content-Type'].must_equal 'text/plain'
|
59
|
+
response['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
60
60
|
response.body.must_equal ['Internal server error']
|
61
61
|
end
|
62
62
|
|
@@ -64,7 +64,7 @@ describe Rasti::Web::Render do
|
|
64
64
|
render.text 'Encoded text', 'Content-Encoding' => 'gzip'
|
65
65
|
|
66
66
|
response.status.must_equal 200
|
67
|
-
response['Content-Type'].must_equal 'text/plain'
|
67
|
+
response['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
68
68
|
response['Content-Encoding'].must_equal 'gzip'
|
69
69
|
response.body.must_equal ['Encoded text']
|
70
70
|
end
|
@@ -73,7 +73,7 @@ describe Rasti::Web::Render do
|
|
73
73
|
render.text 'Not found', 404, 'Content-Encoding' => 'gzip'
|
74
74
|
|
75
75
|
response.status.must_equal 404
|
76
|
-
response['Content-Type'].must_equal 'text/plain'
|
76
|
+
response['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
77
77
|
response['Content-Encoding'].must_equal 'gzip'
|
78
78
|
response.body.must_equal ['Not found']
|
79
79
|
end
|
@@ -86,7 +86,7 @@ describe Rasti::Web::Render do
|
|
86
86
|
render.html '<h1>Title</h1>'
|
87
87
|
|
88
88
|
response.status.must_equal 200
|
89
|
-
response['Content-Type'].must_equal 'text/html'
|
89
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
90
90
|
response.body.must_equal ['<h1>Title</h1>']
|
91
91
|
end
|
92
92
|
|
@@ -94,7 +94,7 @@ describe Rasti::Web::Render do
|
|
94
94
|
render.html '<h1>Internal server error</h1>', 500
|
95
95
|
|
96
96
|
response.status.must_equal 500
|
97
|
-
response['Content-Type'].must_equal 'text/html'
|
97
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
98
98
|
response.body.must_equal ['<h1>Internal server error</h1>']
|
99
99
|
end
|
100
100
|
|
@@ -102,7 +102,7 @@ describe Rasti::Web::Render do
|
|
102
102
|
render.html '<p>Encoded text</p>', 'Content-Encoding' => 'gzip'
|
103
103
|
|
104
104
|
response.status.must_equal 200
|
105
|
-
response['Content-Type'].must_equal 'text/html'
|
105
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
106
106
|
response['Content-Encoding'].must_equal 'gzip'
|
107
107
|
response.body.must_equal ['<p>Encoded text</p>']
|
108
108
|
end
|
@@ -111,7 +111,7 @@ describe Rasti::Web::Render do
|
|
111
111
|
render.html '<h1>Not found</h1>', 404, 'Content-Encoding' => 'gzip'
|
112
112
|
|
113
113
|
response.status.must_equal 404
|
114
|
-
response['Content-Type'].must_equal 'text/html'
|
114
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
115
115
|
response['Content-Encoding'].must_equal 'gzip'
|
116
116
|
response.body.must_equal ['<h1>Not found</h1>']
|
117
117
|
end
|
@@ -126,7 +126,7 @@ describe Rasti::Web::Render do
|
|
126
126
|
render.json object
|
127
127
|
|
128
128
|
response.status.must_equal 200
|
129
|
-
response['Content-Type'].must_equal 'application/json'
|
129
|
+
response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
130
130
|
response.body.must_equal [object.to_json]
|
131
131
|
end
|
132
132
|
|
@@ -134,7 +134,7 @@ describe Rasti::Web::Render do
|
|
134
134
|
render.json '{"x":1,"y":2}'
|
135
135
|
|
136
136
|
response.status.must_equal 200
|
137
|
-
response['Content-Type'].must_equal 'application/json'
|
137
|
+
response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
138
138
|
response.body.must_equal ['{"x":1,"y":2}']
|
139
139
|
end
|
140
140
|
|
@@ -142,7 +142,7 @@ describe Rasti::Web::Render do
|
|
142
142
|
render.json object, 422
|
143
143
|
|
144
144
|
response.status.must_equal 422
|
145
|
-
response['Content-Type'].must_equal 'application/json'
|
145
|
+
response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
146
146
|
response.body.must_equal [object.to_json]
|
147
147
|
end
|
148
148
|
|
@@ -150,7 +150,7 @@ describe Rasti::Web::Render do
|
|
150
150
|
render.json object, 'Content-Encoding' => 'gzip'
|
151
151
|
|
152
152
|
response.status.must_equal 200
|
153
|
-
response['Content-Type'].must_equal 'application/json'
|
153
|
+
response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
154
154
|
response['Content-Encoding'].must_equal 'gzip'
|
155
155
|
response.body.must_equal [object.to_json]
|
156
156
|
end
|
@@ -159,7 +159,7 @@ describe Rasti::Web::Render do
|
|
159
159
|
render.json object, 422, 'Content-Encoding' => 'gzip'
|
160
160
|
|
161
161
|
response.status.must_equal 422
|
162
|
-
response['Content-Type'].must_equal 'application/json'
|
162
|
+
response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
163
163
|
response['Content-Encoding'].must_equal 'gzip'
|
164
164
|
response.body.must_equal [object.to_json]
|
165
165
|
end
|
@@ -172,7 +172,7 @@ describe Rasti::Web::Render do
|
|
172
172
|
render.js 'alert("hello");'
|
173
173
|
|
174
174
|
response.status.must_equal 200
|
175
|
-
response['Content-Type'].must_equal 'application/javascript'
|
175
|
+
response['Content-Type'].must_equal 'application/javascript; charset=utf-8'
|
176
176
|
response.body.must_equal ['alert("hello");']
|
177
177
|
end
|
178
178
|
|
@@ -180,7 +180,7 @@ describe Rasti::Web::Render do
|
|
180
180
|
render.js 'alert("hello");', 206
|
181
181
|
|
182
182
|
response.status.must_equal 206
|
183
|
-
response['Content-Type'].must_equal 'application/javascript'
|
183
|
+
response['Content-Type'].must_equal 'application/javascript; charset=utf-8'
|
184
184
|
response.body.must_equal ['alert("hello");']
|
185
185
|
end
|
186
186
|
|
@@ -188,7 +188,7 @@ describe Rasti::Web::Render do
|
|
188
188
|
render.js 'alert("hello");', 'Content-Encoding' => 'gzip'
|
189
189
|
|
190
190
|
response.status.must_equal 200
|
191
|
-
response['Content-Type'].must_equal 'application/javascript'
|
191
|
+
response['Content-Type'].must_equal 'application/javascript; charset=utf-8'
|
192
192
|
response['Content-Encoding'].must_equal 'gzip'
|
193
193
|
response.body.must_equal ['alert("hello");']
|
194
194
|
end
|
@@ -197,7 +197,7 @@ describe Rasti::Web::Render do
|
|
197
197
|
render.js 'alert("hello");', 206, 'Content-Encoding' => 'gzip'
|
198
198
|
|
199
199
|
response.status.must_equal 206
|
200
|
-
response['Content-Type'].must_equal 'application/javascript'
|
200
|
+
response['Content-Type'].must_equal 'application/javascript; charset=utf-8'
|
201
201
|
response['Content-Encoding'].must_equal 'gzip'
|
202
202
|
response.body.must_equal ['alert("hello");']
|
203
203
|
end
|
@@ -248,7 +248,7 @@ describe Rasti::Web::Render do
|
|
248
248
|
render.partial 'context_and_locals', title: 'Welcome', text: 'Hello world'
|
249
249
|
|
250
250
|
response.status.must_equal 200
|
251
|
-
response['Content-Type'].must_equal 'text/html'
|
251
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
252
252
|
response.body.must_equal ['<h1>Welcome</h1><div>Hello world</div>']
|
253
253
|
end
|
254
254
|
|
@@ -258,7 +258,7 @@ describe Rasti::Web::Render do
|
|
258
258
|
render.layout { 'Page content' }
|
259
259
|
|
260
260
|
response.status.must_equal 200
|
261
|
-
response['Content-Type'].must_equal 'text/html'
|
261
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
262
262
|
response.body.must_equal ['<html><body>Page content</body></html>']
|
263
263
|
end
|
264
264
|
|
@@ -266,7 +266,7 @@ describe Rasti::Web::Render do
|
|
266
266
|
render.layout('custom_layout') { 'Page content' }
|
267
267
|
|
268
268
|
response.status.must_equal 200
|
269
|
-
response['Content-Type'].must_equal 'text/html'
|
269
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
270
270
|
response.body.must_equal ['<html><body class="custom">Page content</body></html>']
|
271
271
|
end
|
272
272
|
|
@@ -274,7 +274,7 @@ describe Rasti::Web::Render do
|
|
274
274
|
render.layout
|
275
275
|
|
276
276
|
response.status.must_equal 200
|
277
|
-
response['Content-Type'].must_equal 'text/html'
|
277
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
278
278
|
response.body.must_equal ['<html><body></body></html>']
|
279
279
|
end
|
280
280
|
|
@@ -286,7 +286,7 @@ describe Rasti::Web::Render do
|
|
286
286
|
render.view 'context_and_locals', title: 'Welcome', text: 'Hello world'
|
287
287
|
|
288
288
|
response.status.must_equal 200
|
289
|
-
response['Content-Type'].must_equal 'text/html'
|
289
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
290
290
|
response.body.must_equal ['<html><body><h1>Welcome</h1><div>Hello world</div></body></html>']
|
291
291
|
end
|
292
292
|
|
@@ -294,7 +294,7 @@ describe Rasti::Web::Render do
|
|
294
294
|
render.view 'context_and_locals', {title: 'Welcome', text: 'Hello world'}, 'custom_layout'
|
295
295
|
|
296
296
|
response.status.must_equal 200
|
297
|
-
response['Content-Type'].must_equal 'text/html'
|
297
|
+
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
298
298
|
response.body.must_equal ['<html><body class="custom"><h1>Welcome</h1><div>Hello world</div></body></html>']
|
299
299
|
end
|
300
300
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasti-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|