Sha256: 60125aa9a7e9cfa208dca0331ee6f854e8ece8c4ae9b4dfbbfac011463bbcec1

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require "spec_helper"

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

  describe "#initialize" do
    subject { response }

    it { should be_a Redbooth::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

1 entries across 1 versions & 1 rubygems

Version Path
redbooth-ruby-0.0.2 spec/redbooth/request/response_spec.rb