Sha256: d2c21a58532ae8b66d747ce7d7d636b651c164e998c716212c638f1a9a52cf00

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 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 => Yajl::Encoder.encode(body)))

    subject.call(env)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_client-0.3.3 spec/api_client/connection/request/json_spec.rb
api_client-0.3.2 spec/api_client/connection/request/json_spec.rb