Skip to content

Commit 43eb55e

Browse files
committed
Add JSONP tests
1 parent 7af58e9 commit 43eb55e

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

test.rb

+36-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def app
2121
should "return ok" do
2222
assert last_response.ok?
2323
end
24-
should "have some kind of welcome" do
24+
should "include an example" do
2525
assert last_response.body =~ /curl/
2626
end
2727
end
@@ -33,9 +33,24 @@ def app
3333
should "return ok" do
3434
assert last_response.ok?
3535
end
36-
should "return json conent-type" do
36+
should "return json content-type" do
37+
assert_equal 'application/json;charset=ascii-8bit', last_response.headers['Content-Type']
38+
end
39+
end
40+
41+
context "on GET to /:ip?variable=myVariableName" do
42+
setup {
43+
get '/67.161.92.71?variable=myVariableName'
44+
}
45+
should "return ok" do
46+
assert last_response.ok?
47+
end
48+
should "return json content-type" do
3749
assert_equal 'application/json;charset=ascii-8bit', last_response.headers['Content-Type']
3850
end
51+
should "include a variable" do
52+
assert last_response.body =~ /var myVariableName/
53+
end
3954
end
4055

4156
context "on GET to /:ip?callback=myCallbackFunction" do
@@ -48,11 +63,29 @@ def app
4863
should "return json content-type" do
4964
assert_equal 'application/json;charset=ascii-8bit', last_response.headers['Content-Type']
5065
end
51-
should "have a function as result" do
66+
should "include a function" do
5267
assert last_response.body =~ /myCallbackFunction\(\{.*\}\)/
5368
end
5469
end
5570

71+
context "on GET to /:ip?callback=myCallbackFunction&variable=myVariableName" do
72+
setup {
73+
get '/67.161.92.71?callback=myCallbackFunction&variable=myVariableName'
74+
}
75+
should "return ok" do
76+
assert last_response.ok?
77+
end
78+
should "return json content-type" do
79+
assert_equal 'application/json;charset=ascii-8bit', last_response.headers['Content-Type']
80+
end
81+
should "include a variable" do
82+
assert last_response.body =~ /var myVariableName/
83+
end
84+
should "include a function" do
85+
assert last_response.body =~ /myCallbackFunction\(myVariableName\);/
86+
end
87+
end
88+
5689
context "converting struct" do
5790
setup {
5891
Struct.new(

0 commit comments

Comments
 (0)