Sha256: d21d188704e56f5317a6819d4562d43aa52ea2259049ed6eaa2ec2d8d2feb095

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe RackBox, 'POSTing data' do

  before do
    @rack_app1 = lambda {|env| [ 200, { }, "you POSTed data: #{ env['rack.input'].read }" ] }  
    @rack_app2 = lambda {|env| 
      req = Rack::Request.new env
      [ 200, { }, "you POSTed data: #{ req.body.read }" ]
    }  
    @method_app = lambda {|env| [ 200, { }, "method: #{ env['REQUEST_METHOD'] }" ] }
  end

  it 'should make it easy to POST data, eg. curl -D "XML"' do
    RackBox.request(@rack_app1, '/', :data => 'hi there').body.should include('you POSTed data: hi there')
    RackBox.request(@rack_app2, '/', :data => 'hi there').body.should include('you POSTed data: hi there')
  end

  it "should default to POST if method isn't explicitly set and we set :data" do
    RackBox.request(@method_app, '/').body.should include('method: GET')
    RackBox.request(@method_app, '/', :method => :put).body.should include('method: PUT')
    RackBox.request(@method_app, '/', :data => 'hi').body.should include('method: POST')
    RackBox.request(@method_app, '/', :data => 'hi', :method => :put).body.should include('method: PUT')
  end

  it "should default to POST if method isn't explicitly set and we set :params" do
    RackBox.request(@method_app, '/').body.should include('method: GET')
    RackBox.request(@method_app, '/', :method => :put).body.should include('method: PUT')
    RackBox.request(@method_app, '/', :params => { :x => 5 }).body.should include('method: POST')
    RackBox.request(@method_app, '/', :params => { :x => 5 }, :method => :put).body.should include('method: PUT')
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
remi-rackbox-1.1.1 spec/posting_data_spec.rb
remi-rackbox-1.1.2 spec/posting_data_spec.rb
remi-rackbox-1.1.3 spec/posting_data_spec.rb
remi-rackbox-1.1.4 spec/posting_data_spec.rb
remi-rackbox-1.1.5 spec/posting_data_spec.rb
remi-rackbox-1.1.6 spec/posting_data_spec.rb
eol_rackbox-1.1.7 spec/posting_data_spec.rb