Sha256: 7d17123f5ca09b6a60cffd60ac2f555c5e6781295823aa989e252f863dabab20

Contents?: true

Size: 929 Bytes

Versions: 8

Compression:

Stored size: 929 Bytes

Contents

require 'spec_helper'

describe RedboothRuby::Request::Response do
  let(:headers) { {} }
  let(:status) { 200 }
  let(:body) { '{"response":"ok"}' }
  let(:response) { RedboothRuby::Request::Response.new(body: body,
                                                   status: status,
                                                   headers: headers) }

  describe '#initialize' do
    subject { response }

    it { should be_a RedboothRuby::Request::Response }
    it { expect(subject.data).to eq('response' => 'ok') }
    it { expect(subject.body).to eq(body) }
    it { expect(subject.headers).to eq(headers) }
    it { expect(subject.status).to eq(status) }

    context 'with wrong json body' do
      let(:body) { '<html> asdfasdf </html>' }

      it { expect(subject.data).to be_empty }
    end

    context 'with empty body' do
      let(:body) { nil }

      it { expect(subject.data).to be_empty }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redbooth-ruby-0.2.3 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.2.2 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.2.1 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.2.0 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.1.4 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.1.3 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.1.1 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.1.0 spec/redbooth-ruby/request/response_spec.rb