Sha256: 5c8c01141035c74c9e53ab0cca898dd172399f4e02681a4a1ddbc1517680d69a

Contents?: true

Size: 998 Bytes

Versions: 5

Compression:

Stored size: 998 Bytes

Contents

require 'test_xml/test_unit'

ActionController::TestCase.class_eval do
  # FIXME: ugly monkey-patching.
  # TODO: test:
  #   put :create
  #   put :create, :format => :xml
  #   put :create, "<order/>", :format => :xml
  #   put :create, "<order/>"
  def process(action, *args)
    if args.first.is_a?(String)
       request.env['RAW_POST_DATA'] = args.shift
       method = args.pop
       args << nil
       args << method
    end
    
    super
  end
  
  def assert_response(status, headers={})  # FIXME: allow message.
    super
    
    if headers.is_a?(Hash)
      assert_headers(headers)
    else
      assert_body(headers)
    end
  end
  
  def assert_headers(headers)
    headers.each_pair do |k,v|
      assert_equal v, @response.headers[k]
    end
  end
  
  def assert_body(body, options={})
    return assert_xml_equal body, @response.body if options[:format] == :xml  # FIXME: how do we know whether assert_xml is appropriate?
    assert_equal body, @response.body
  end
  
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roar-0.9.0 lib/roar/rails/test_case.rb
roar-0.8.3 lib/roar/rails/test_case.rb
roar-0.8.2 lib/roar/rails/test_case.rb
roar-0.8.1 lib/roar/rails/test_case.rb
roar-0.8.0 lib/roar/rails/test_case.rb