Sha256: 48bbb92f4694671d0039563cf0704909989741cd52b8c89ce85b8a2f02bff2b9

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 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

3 entries across 3 versions & 1 rubygems

Version Path
redbooth-ruby-0.0.5 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.0.4 spec/redbooth-ruby/request/response_spec.rb
redbooth-ruby-0.0.3 spec/redbooth-ruby/request/response_spec.rb