Sha256: bf4dd35789a9cf323d536e31dca58ebe7b147148895b9b69daf4e91094a9770e

Contents?: true

Size: 697 Bytes

Versions: 4

Compression:

Stored size: 697 Bytes

Contents

require "spec_helper"

describe ApiClient::Connection::Middlewares::Request::Json do
  let(:app) { mock }
  let(:body) { {:some => :data} }
  let(:env) do
    {
      :url => "http://api.twitter.com",
      :request_headers => {},
      :method => "post",
      :body => body
    }
  end

  subject { ApiClient::Connection::Middlewares::Request::Json.new(app) }

  it "sets content type to json" do
    app.should_receive(:call).
      with(hash_including(:request_headers => {"Content-Type" => "application/json"}))

    subject.call(env)
  end

  it "JSON encodes body" do
    app.should_receive(:call).
      with(hash_including(:body => MultiJson.dump(body)))

    subject.call(env)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_client-0.4.3 spec/api_client/connection/request/json_spec.rb
api_client-0.4.2 spec/api_client/connection/request/json_spec.rb
api_client-0.4.1 spec/api_client/connection/request/json_spec.rb
api_client-0.4.0 spec/api_client/connection/request/json_spec.rb