Skip to content

Commit

Permalink
Document how to use URL params with DELETE method (#220)
Browse files Browse the repository at this point in the history
* restore ability to set URL params for DELETE method
* make DELETE method acts as POST
* fix pr remarks
  • Loading branch information
tpltn authored and perlun committed Mar 10, 2018
1 parent af6bbb4 commit 575a689
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class HomepageTest < Test::Unit::TestCase
# parameters, so make sure that `json` below is already a JSON-serialized string.
post(uri, json, { 'CONTENT_TYPE' => 'application/json' })
end

def delete_with_url_params_and_body
delete '/?foo=bar', JSON.generate('baz' => 'zot')
end
end
```

Expand Down
20 changes: 20 additions & 0 deletions spec/rack/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,26 @@ def verb
def verb
'delete'
end

it 'uses the provided params hash' do
delete '/', foo: 'bar'
expect(last_request.GET).to eq({})
expect(last_request.POST).to eq('foo' => 'bar')
expect(last_request.body.read).to eq('foo=bar')
end

it 'accepts params in the path' do
delete '/?foo=bar'
expect(last_request.GET).to eq('foo' => 'bar')
expect(last_request.POST).to eq({})
expect(last_request.body.read).to eq('')
end

it 'accepts a body' do
delete '/', 'Lobsterlicious!'
expect(last_request.GET).to eq({})
expect(last_request.body.read).to eq('Lobsterlicious!')
end
end

describe '#options' do
Expand Down

0 comments on commit 575a689

Please sign in to comment.