/
riot_macros_test.rb
43 lines (36 loc) · 1.21 KB
/
riot_macros_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'teststrap'
context "Riot Macros Test:" do
setup do
mock_app {
helpers Sinatra::Chicago::Responders
get("/redirector") { redirect '/foo/bar' }
get("/basic-json") do
content_type 'application/json'
{:foo => "bar"}.to_json
end
get("/json-with-content-type") do
content_type 'text/javascript', :charset => "utf-8"
{:foo => "bar"}.to_json
end
}
end
context "asserts redirected to" do
setup { get('/redirector') }
asserts_redirected_to('/foo/bar')
end # asserts redirected to
context "json response" do
context "basic" do
setup { get('/basic-json') }
asserts_json_response({:foo => "bar"})
end # basic
context "with special content-type" do
setup { get('/json-with-content-type') }
asserts_json_response("text/javascript;charset=utf-8", {:foo => "bar"})
end # with special content-type
context "with content expectation provided as block" do
helper(:bar_value) { "bar" }
setup { get('/json-with-content-type') }
asserts_json_response("text/javascript;charset=utf-8") { {:foo => bar_value}.to_json }
end # with content expectation provided as block
end # json response
end