thumblemonks-chicago 0.3.2.1 → 0.3.2.2
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.
- data/chicago.gemspec +1 -1
- data/lib/chicago/protest/macros.rb +11 -15
- metadata +1 -1
data/chicago.gemspec
CHANGED
|
@@ -4,41 +4,37 @@ module Chicago
|
|
|
4
4
|
module Protest
|
|
5
5
|
module Macros
|
|
6
6
|
def asserts_response_status(expected)
|
|
7
|
-
asserts("response status").equals(expected) { last_response.status }
|
|
7
|
+
asserts("response status is #{expected}").equals(expected) { last_response.status }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def asserts_content_type(expected)
|
|
11
|
-
asserts("content type").equals(expected) { last_response.headers['Content-type'] }
|
|
11
|
+
asserts("content type is #{expected}").equals(expected) { last_response.headers['Content-type'] }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def asserts_response_body(expected)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
asserts("response body matches #{expected.inspect}").matches(expected) { last_response.body }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def asserts_location(expected_path)
|
|
19
|
+
asserts("location matches #{expected_path}").matches(expected_path) do
|
|
20
|
+
last_response.headers["Location"]
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def asserts_json_response(json, &block)
|
|
23
25
|
asserts_content_type 'application/json'
|
|
24
|
-
asserts("response body has JSON") do
|
|
26
|
+
asserts("response body has JSON").equals(last_response.body) do
|
|
25
27
|
json = json.to_json unless json.instance_of?(String)
|
|
26
|
-
|
|
28
|
+
json
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
# Usage:
|
|
31
33
|
# assert_redirected_to '/foo/bar'
|
|
34
|
+
# assert_redirected_to %r[foo/bar]
|
|
32
35
|
def asserts_redirected_to(expected_path)
|
|
33
36
|
asserts_response_status 302
|
|
34
37
|
asserts_location expected_path
|
|
35
|
-
# TODO: implement a matches operator
|
|
36
|
-
# action = expected_path.kind_of?(Regexp) ? 'match' : 'equal'
|
|
37
|
-
# send("assert_#{action}", expected_path, last_response.headers["Location"])
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def asserts_location(expected_path)
|
|
41
|
-
asserts("location header").equals(expected_path) { last_response.headers["Location"] }
|
|
42
38
|
end
|
|
43
39
|
end # Macros
|
|
44
40
|
end # Protest
|