Sha256: 6489fe2a57c4e217a2abefc3d225f74032fa68d5730433b728fe0a5669863a0d

Contents?: true

Size: 1.27 KB

Versions: 19

Compression:

Stored size: 1.27 KB

Contents

require 'saddle'

describe Saddle::Client do

  context "POST requests" do
    context "using the default client" do

      before :each do
        @stubs = Faraday::Adapter::Test::Stubs.new
        @default_client = Saddle::Client.create(:stubs => @stubs)
      end

      it "should post empty" do
        @stubs.post('/test') {
          [
            200,
            {},
            'Party on!',
          ]
        }
        @default_client.requester.post('/test').should == 'Party on!'
      end

      it "should post url encoded" do
        @stubs.post('/test', 'a=0&b=true&c=Wingdings') {
          [
            200,
            {},
            'Party on!',
          ]
        }
        @default_client.requester.post(
          '/test',
          {'a' => 0, 'b' => true, 'c' => 'Wingdings'},
          {:request_style => :urlencoded}
        ).should == 'Party on!'
      end

      it "should post JSON encoded" do
        @stubs.post('/test', '{"a":0,"b":true,"c":"Wingdings"}') {
          [
            200,
            {},
            'Party on!',
          ]
        }
        @default_client.requester.post(
          '/test',
          {'a' => 0, 'b' => true, 'c' => 'Wingdings'},
          {:request_style => :json}
        ).should == 'Party on!'
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
saddle-0.0.31 spec/requester/post_spec.rb
saddle-0.0.30 spec/requester/post_spec.rb
saddle-0.0.27 spec/requester/post_spec.rb
saddle-0.0.26 spec/requester/post_spec.rb
saddle-0.0.25 spec/requester/post_spec.rb
saddle-0.0.23 spec/requester/post_spec.rb
saddle-0.0.22 spec/requester/post_spec.rb
saddle-0.0.21 spec/requester/post_spec.rb
saddle-0.0.19 spec/requester/post_spec.rb
saddle-0.0.18 spec/requester/post_spec.rb
saddle-0.0.17 spec/requester/post_spec.rb
saddle-0.0.16 spec/requester/post_spec.rb
saddle-0.0.15 spec/requester/post_spec.rb
saddle-0.0.14 spec/requester/post_spec.rb
saddle-0.0.12 spec/requester/post_spec.rb
saddle-0.0.11 spec/requester/post_spec.rb
saddle-0.0.10 spec/requester/post_spec.rb
saddle-0.0.7 spec/requester/post_spec.rb
saddle-0.0.6 spec/requester/post_spec.rb