Sha256: ba4bd7456efb5a0b26d3df7e793ffebe34ea90f3272bfa96f66fb8d306591a50

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'


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

15 entries across 15 versions & 1 rubygems

Version Path
saddle-0.0.49 spec/requester/post_spec.rb
saddle-0.0.48 spec/requester/post_spec.rb
saddle-0.0.46 spec/requester/post_spec.rb
saddle-0.0.45 spec/requester/post_spec.rb
saddle-0.0.44 spec/requester/post_spec.rb
saddle-0.0.43 spec/requester/post_spec.rb
saddle-0.0.42 spec/requester/post_spec.rb
saddle-0.0.41 spec/requester/post_spec.rb
saddle-0.0.38 spec/requester/post_spec.rb
saddle-0.0.37 spec/requester/post_spec.rb
saddle-0.0.36 spec/requester/post_spec.rb
saddle-0.0.35 spec/requester/post_spec.rb
saddle-0.0.34 spec/requester/post_spec.rb
saddle-0.0.33 spec/requester/post_spec.rb
saddle-0.0.32 spec/requester/post_spec.rb