Sha256: 21a2d1903c8623e95c3ef8f71f3f015d3e43c46cfb1a14b48a8d566aec1620d2

Contents?: true

Size: 834 Bytes

Versions: 11

Compression:

Stored size: 834 Bytes

Contents

require 'spec_helper'

include Restspec::Endpoints

describe Request do
  let(:request) do
    Request.new(:get, '/url', {'header' => 'header'}, {'payload' => 'payload'})
  end

  it 'is a bag for request data' do
    expect(request.method).to eq(:get)
    expect(request.url).to eq('/url')
    expect(request.headers).to eq({'header' => 'header'})
    expect(request.payload).to eq({'payload' => 'payload'})
  end

  describe '#endpoint=' do
    let(:endpoint) { double }

    it 'injects an endpoint' do
      request.endpoint = endpoint
      expect(request.endpoint).to eq(endpoint)
    end
  end

  describe '#raw_payload' do
    it 'is the raw payload to send through the wire json encoded' do
      request.payload = { 'hola' => 'mundo' }
      expect(JSON.parse(request.raw_payload)).to eq(request.payload)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restspec-0.3.2 spec/restspec/endpoints/request_spec.rb
restspec-0.3.1 spec/restspec/endpoints/request_spec.rb
restspec-0.3.0 spec/restspec/endpoints/request_spec.rb
restspec-0.2.6 spec/restspec/endpoints/request_spec.rb
restspec-0.2.5 spec/restspec/endpoints/request_spec.rb
restspec-0.2.4 spec/restspec/endpoints/request_spec.rb
restspec-0.2.3 spec/restspec/endpoints/request_spec.rb
restspec-0.2.2 spec/restspec/endpoints/request_spec.rb
restspec-0.2.1 spec/restspec/endpoints/request_spec.rb
restspec-0.2 spec/restspec/endpoints/request_spec.rb
restspec-0.1 spec/restspec/endpoints/request_spec.rb