diff --git a/README.md b/README.md index 1be7af10..b043fce2 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/spec/rack/test_spec.rb b/spec/rack/test_spec.rb index f4beb90a..01b759bf 100644 --- a/spec/rack/test_spec.rb +++ b/spec/rack/test_spec.rb @@ -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