Skip to content

Commit

Permalink
Ported to latest protest
Browse files Browse the repository at this point in the history
  • Loading branch information
gus committed Jul 5, 2009
1 parent 181983d commit 495b7bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -15,7 +15,7 @@ task :test => [:set_test_env, :environment] do
require 'protest'
$:.concat ['./lib', './test']
Dir.glob("./test/*_test.rb").each { |test| require test }
Protest.run
Protest.report
end

desc "Open an irb session preloaded with this library"
Expand Down
14 changes: 7 additions & 7 deletions lib/chicago/protest/macros.rb
Expand Up @@ -4,29 +4,29 @@ module Chicago
module Protest
module Macros
def asserts_response_status(expected)
asserts("response status is #{expected}").equals(expected) { last_response.status }
asserts("response status is #{expected}") { last_response.status }.equals(expected)
end

def asserts_content_type(expected)
asserts("content type is #{expected}").equals(expected) { last_response.headers['Content-type'] }
asserts("content type is #{expected}") { last_response.headers['Content-type'] }.equals(expected)
end

def asserts_response_body(expected)
asserts("response body matches #{expected.inspect}").matches(expected) { last_response.body }
asserts("response body matches #{expected.inspect}") { last_response.body }.matches(expected)
end

def asserts_location(expected_path)
asserts("location matches #{expected_path}").matches(expected_path) do
asserts("location matches #{expected_path}") do
last_response.headers["Location"]
end
end.matches(expected_path)
end

def asserts_json_response(json, &block)
asserts_content_type 'application/json'
asserts("response body has JSON").equals(last_response.body) do
asserts("response body has JSON") do
json = json.to_json unless json.instance_of?(String)
json
end
end.equals(last_response.body)
end

# Usage:
Expand Down

0 comments on commit 495b7bb

Please sign in to comment.