@@ -3,7 +3,7 @@ require "./spec_helper"
33describe " Context" do
44 context " headers" do
55 it " sets content type" do
6- http_handler = Grip ::Routers :: Http .new
6+ http_handler = Grip ::Handlers :: HTTP .new
77 http_handler.add_route " GET" , " /content_type" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
88 context.response.headers.merge!({" Content-Type" => " application/json" })
99 context
@@ -15,7 +15,7 @@ describe "Context" do
1515 end
1616
1717 it " parses headers" do
18- http_handler = Grip ::Routers :: Http .new
18+ http_handler = Grip ::Handlers :: HTTP .new
1919 http_handler.add_route " GET" , " /headers" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
2020 name = context.request.headers[" name" ]
2121 context.response.print(" Hello #{ name } " )
@@ -30,7 +30,7 @@ describe "Context" do
3030 end
3131
3232 it " sets response headers" do
33- http_handler = Grip ::Routers :: Http .new
33+ http_handler = Grip ::Handlers :: HTTP .new
3434 http_handler.add_route " GET" , " /response_headers" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
3535 context.response.headers.add " Accept-Language" , " ge"
3636 context
@@ -45,7 +45,7 @@ describe "Context" do
4545 context " methods" do
4646 it " sends a local file" do
4747 file_path = File .join(__DIR__, " ./fixtures/index.html" )
48- http_handler = Grip ::Routers :: Http .new
48+ http_handler = Grip ::Handlers :: HTTP .new
4949 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
5050 context.send_file(file_path).halt
5151 end
@@ -57,9 +57,9 @@ describe "Context" do
5757 end
5858
5959 it " has binary() method with octet-stream" do
60- http_handler = Grip ::Routers :: Http .new
60+ http_handler = Grip ::Handlers :: HTTP .new
6161 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
62- context.binary(10 ).halt
62+ context.binary(" 10 " ).halt
6363 end
6464
6565 request = HTTP ::Request .new(" GET" , " /" )
@@ -69,7 +69,7 @@ describe "Context" do
6969 end
7070
7171 it " encodes text in utf-8" do
72- http_handler = Grip ::Routers :: Http .new
72+ http_handler = Grip ::Handlers :: HTTP .new
7373 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
7474 context.text(" 👋🏼 grip" ).halt
7575 end
@@ -81,7 +81,7 @@ describe "Context" do
8181 end
8282
8383 it " encodes html in utf-8" do
84- http_handler = Grip ::Routers :: Http .new
84+ http_handler = Grip ::Handlers :: HTTP .new
8585 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
8686 context.html(" 👋🏼 grip" ).halt
8787 end
@@ -95,7 +95,7 @@ describe "Context" do
9595
9696 context " methods" do
9797 it " allows overriding text() content type" do
98- http_handler = Grip ::Routers :: Http .new
98+ http_handler = Grip ::Handlers :: HTTP .new
9999 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
100100 context.text(" 👋🏼 grip" , " text/html" ).halt
101101 end
@@ -106,7 +106,7 @@ describe "Context" do
106106 end
107107
108108 it " allows overriding json() content type" do
109- http_handler = Grip ::Routers :: Http .new
109+ http_handler = Grip ::Handlers :: HTTP .new
110110 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
111111 context.json({:message => " 👋🏼 grip" }, " application/json" ).halt
112112 end
@@ -117,7 +117,7 @@ describe "Context" do
117117 end
118118
119119 it " allows overriding html() content type" do
120- http_handler = Grip ::Routers :: Http .new
120+ http_handler = Grip ::Handlers :: HTTP .new
121121 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
122122 context.html(" 👋🏼 grip" , " text/html" ).halt
123123 end
@@ -128,9 +128,9 @@ describe "Context" do
128128 end
129129
130130 it " allows overriding binary() content type" do
131- http_handler = Grip ::Routers :: Http .new
131+ http_handler = Grip ::Handlers :: HTTP .new
132132 http_handler.add_route " GET" , " /" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
133- context.binary(10 , " multipart/encrypted" ).halt
133+ context.binary(" 10 " , " multipart/encrypted" ).halt
134134 end
135135
136136 request = HTTP ::Request .new(" GET" , " /" )
@@ -141,7 +141,7 @@ describe "Context" do
141141
142142 context " cookies" do
143143 it " sets cookie" do
144- http_handler = Grip ::Routers :: Http .new
144+ http_handler = Grip ::Handlers :: HTTP .new
145145 http_handler.add_route " GET" , " /cookies" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
146146 context.put_resp_cookie(HTTP ::Cookie .new(" Foo" , " Bar" )).halt
147147 end
@@ -154,7 +154,7 @@ describe "Context" do
154154 end
155155
156156 it " sets string cookie" do
157- http_handler = Grip ::Routers :: Http .new
157+ http_handler = Grip ::Handlers :: HTTP .new
158158 http_handler.add_route " GET" , " /cookies" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
159159 context.put_resp_cookie(" Foo" , " Bar" ).halt
160160 end
@@ -167,7 +167,7 @@ describe "Context" do
167167 end
168168
169169 it " sets multiple cookie" do
170- http_handler = Grip ::Routers :: Http .new
170+ http_handler = Grip ::Handlers :: HTTP .new
171171 http_handler.add_route " GET" , " /cookies" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
172172 context.put_resp_cookie(" Foo" , " Bar" ).put_resp_cookie(" Qux" , " Baz" ).halt
173173 end
@@ -181,7 +181,7 @@ describe "Context" do
181181 end
182182
183183 it " overrides cookie" do
184- http_handler = Grip ::Routers :: Http .new
184+ http_handler = Grip ::Handlers :: HTTP .new
185185 http_handler.add_route " GET" , " /cookies" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
186186 context.put_resp_cookie(" Foo" , " Bar" ).put_resp_cookie(" Foo" , " Baz" ).halt
187187 end
@@ -194,7 +194,7 @@ describe "Context" do
194194 end
195195
196196 it " gets correkt cookie" do
197- http_handler = Grip ::Routers :: Http .new
197+ http_handler = Grip ::Handlers :: HTTP .new
198198 http_handler.add_route " GET" , " /get_cookie" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
199199 cookie = context.get_req_cookie(" Foo" )
200200 if cookie
@@ -213,7 +213,7 @@ describe "Context" do
213213 end
214214
215215 it " gets nil for not existing cookie" do
216- http_handler = Grip ::Routers :: Http .new
216+ http_handler = Grip ::Handlers :: HTTP .new
217217 http_handler.add_route " GET" , " /get_cookie" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
218218 cookie = context.get_req_cookie(" Baz" )
219219 if cookie
@@ -235,7 +235,7 @@ describe "Context" do
235235
236236 context " redirects" do
237237 it " redirects to home page when called without arguments" do
238- http_handler = Grip ::Routers :: Http .new
238+ http_handler = Grip ::Handlers :: HTTP .new
239239 http_handler.add_route " GET" , " /redirect_to_home" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
240240 context.redirect
241241 end
@@ -248,7 +248,7 @@ describe "Context" do
248248 end
249249
250250 it " redirects to another url with status code 301 using keyword arguments" do
251- http_handler = Grip ::Routers :: Http .new
251+ http_handler = Grip ::Handlers :: HTTP .new
252252 http_handler.add_route " GET" , " /redirect_to_another_url" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
253253 context.redirect(url: " /another_url" , status_code: 301 )
254254 end
@@ -261,7 +261,7 @@ describe "Context" do
261261 end
262262
263263 it " redirects to another url with status code 308 using positional arguments" do
264- http_handler = Grip ::Routers :: Http .new
264+ http_handler = Grip ::Handlers :: HTTP .new
265265 http_handler.add_route " GET" , " /redirect_to_another_url_with_308" , ExampleController .new, [:none ], - > (context : HTTP ::Server ::Context ) do
266266 context.redirect(" /another_url" , HTTP ::Status ::PERMANENT_REDIRECT )
267267 end
0 commit comments