Sha256: 989425b3f1a0bde2b752eff0233833f9f88df006471e3a4bc5c5868b258b8a15

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe Acfs::Request do
  let(:url)     { 'http://api.example.org/v1/examples' }
  let(:headers) { nil }
  let(:params)  { nil }
  let(:data)    { nil }
  let(:options) { {headers: headers, params: params, data: data} }
  let(:request) { Acfs::Request.new(url, options) }

  describe '#url' do
    it 'should return request URL' do
      expect(request.url).to be == url
    end

    context 'with parameters' do
      let(:params) { { id: 10 }}

      it 'should return URL without query' do
        expect(request.url).to be == "#{url}"
      end
    end

    context 'with parameters in URL' do
      let(:url) { 'http://api.example.org/v1/examples?b=ac' }
      let(:params) { { id: 10 }}

      it 'should strip query from URL' do
        expect(request.url).to be == 'http://api.example.org/v1/examples'
      end
    end
  end

  describe '#headers' do
    let(:headers) { { 'Accept' => 'application/json' } }

    it 'should return request headers' do
      expect(request.headers).to be == headers
    end
  end

  describe '#params' do
    let(:params) { { id: 10 }}

    it 'should return request headers' do
      expect(request.params).to be == params
    end
  end

  describe '#data' do
    let(:data) { { id: 10, name: 'Anon' } }

    it 'should return request data' do
      expect(request.data).to be == data
    end
  end

  describe '#data' do
    context 'with data' do
      let(:data) { { id: 10, name: 'Anon' } }

      it { expect(request).to be_data }
    end

    context 'without data' do
      let(:data) { nil }

      it { expect(request).to_not be_data }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
acfs-0.7.0 spec/acfs/request_spec.rb
acfs-0.6.0 spec/acfs/request_spec.rb
acfs-0.5.1 spec/acfs/request_spec.rb
acfs-0.5.0 spec/acfs/request_spec.rb
acfs-0.4.0 spec/acfs/request_spec.rb
acfs-0.3.0 spec/acfs/request_spec.rb