Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joefiorini committed Jan 10, 2012
1 parent 508352c commit 5f8de53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions lib/roar/rails/test_case.rb
Expand Up @@ -4,38 +4,38 @@ module TestCase
def get(action, *args)
process(action, "GET", *args)
end

def post(action, *args)
process(action, "POST", *args)
end

def put(action, *args)
process(action, "PUT", *args)
end

def delete(action, *args)
process(action, "DELETE", *args)
end

def process(action, http_method, document="", params={})
if document.is_a?(Hash)
params = document
document = ""
end

request.env['RAW_POST_DATA'] = document

super(action, params, nil, nil, http_method) # FIXME: for Rails <=3.1, only.
end

module Assertions
require 'test_xml/test_unit'
def assert_body(body, options={})
return assert_xml_equal body, response.body if options[:xml]
assert_equal body, response.body
end
end

include Assertions
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/dummy/app/representers/singer_representer.rb
@@ -1,9 +1,9 @@
module SingerRepresenter
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia

property :name

link :self do
singer_url(name)
end
Expand Down
10 changes: 5 additions & 5 deletions test/representer_test.rb
Expand Up @@ -2,22 +2,22 @@

class RepresenterTest < ActionController::TestCase
include Roar::Rails::TestCase

tests SingersController

test "representers can use URL helpers" do
get :show, :id => "bumi"
assert_body "{\"name\":\"Bumi\",\"links\":[{\"rel\":\"self\",\"href\":\"http://http://roar.apotomo.de/singers/Bumi\"}]}"
end

test "it works with uninitialized config.representer.default_url_options" do
url_options = Rails.application.config.representer.default_url_options
Rails.application.config.representer.default_url_options = nil

assert_raises ArgumentError do
get :show, :id => "bumi"
end

Rails.application.config.representer.default_url_options = url_options
end
end

0 comments on commit 5f8de53

Please sign in to comment.