Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using latest protest, which includes matches macro

  • Loading branch information...
commit 181983d6ebb4b68e4d7feb5945c972943b153fb7 1 parent cea0114
@gus gus authored
Showing with 12 additions and 16 deletions.
  1. +1 −1  chicago.gemspec
  2. +11 −15 lib/chicago/protest/macros.rb
View
2  chicago.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "chicago"
- s.version = "0.3.2.1"
+ s.version = "0.3.2.2"
s.date = "2009-06-28"
s.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
s.email = %w[gus@gusg.us gabriel.gironda@gmail.com]
View
26 lib/chicago/protest/macros.rb
@@ -4,41 +4,37 @@ module Chicago
module Protest
module Macros
def asserts_response_status(expected)
- asserts("response status").equals(expected) { last_response.status }
+ asserts("response status is #{expected}").equals(expected) { last_response.status }
end
def asserts_content_type(expected)
- asserts("content type").equals(expected) { last_response.headers['Content-type'] }
+ asserts("content type is #{expected}").equals(expected) { last_response.headers['Content-type'] }
end
def asserts_response_body(expected)
- # TODO: implement a matches operator
- asserts("response body").not do
- expected = %r[#{expected}] if expected.kind_of?(String)
- expected.match(last_response.body).nil?
+ asserts("response body matches #{expected.inspect}").matches(expected) { last_response.body }
+ end
+
+ def asserts_location(expected_path)
+ asserts("location matches #{expected_path}").matches(expected_path) do
+ last_response.headers["Location"]
end
end
def asserts_json_response(json, &block)
asserts_content_type 'application/json'
- asserts("response body has JSON") do
+ asserts("response body has JSON").equals(last_response.body) do
json = json.to_json unless json.instance_of?(String)
- last_response.body == json
+ json
end
end
# Usage:
# assert_redirected_to '/foo/bar'
+ # assert_redirected_to %r[foo/bar]
def asserts_redirected_to(expected_path)
asserts_response_status 302
asserts_location expected_path
- # TODO: implement a matches operator
- # action = expected_path.kind_of?(Regexp) ? 'match' : 'equal'
- # send("assert_#{action}", expected_path, last_response.headers["Location"])
- end
-
- def asserts_location(expected_path)
- asserts("location header").equals(expected_path) { last_response.headers["Location"] }
end
end # Macros
end # Protest
Please sign in to comment.
Something went wrong with that request. Please try again.