1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/test/rest_test.rb
Blake Mizerany 307f93c6f1 RESTful testing
To be used in one of two ways:

  post_it '/', :foo => 'bar', :env => { :agent => 'Mac Intel' }

  or

  post_it '/', '<myxml></myxml>', :agent => 'Mac Intel'

to receive this in your EventContext

  For query params:

  post '/' do
    params.inspect
  end

  For XML/JSON/etc.. :

  post '/' do
    request.body.string
  end
2008-04-09 22:50:56 -07:00

16 lines
276 B
Ruby

require File.dirname(__FILE__) + '/helper'
context "RESTful tests" do
specify "should take xml" do
post '/foo.xml' do
request.body.string
end
post_it '/foo.xml', '<myxml></myxml>'
assert ok?
assert_equal('<myxml></myxml>', body)
end
end