Sha256: 16cec040706365dc1a1521744bf2205908d43421c832902bf82cf29a63e8c77c

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true
RSpec.describe SoapyBing::Soap::Response::ReportStatus do
  before do
    stub_const(
      'MyCustomResponse',
      Class
        .new(SoapyBing::Soap::Response::Base)
        .include(described_class)
    )
  end
  let(:response_hash) do
    {
      'Envelope' => {
        'Body' => {
          'MyCustomResponse' => {
            'ReportRequestStatus' => {
              'Status' => nil
            }
          }
        }
      }
    }
  end
  let(:subject) { MyCustomResponse.new(response_hash) }

  describe 'status' do
    before do
      response_hash['Envelope']['Body']['MyCustomResponse']['ReportRequestStatus']
        .merge!('Status' => status)
    end

    context 'when error' do
      let(:status) { 'Error' }

      it '#status is Error' do
        expect(subject.status).to eq status
      end

      it '#error? is false' do
        expect(subject).to be_error
      end

      it '#success? is false' do
        expect(subject).not_to be_success
      end

      it '#pending? is false' do
        expect(subject).not_to be_pending
      end
    end

    context 'when success' do
      let(:status) { 'Success' }

      it '#status is Success' do
        expect(subject.status).to eq status
      end

      it '#error? is false' do
        expect(subject).not_to be_error
      end

      it '#success? is true' do
        expect(subject).to be_success
      end

      it '#pending? is false' do
        expect(subject).not_to be_pending
      end
    end

    context 'when pending' do
      let(:status) { 'Pending' }

      it '#status is Pending' do
        expect(subject.status).to eq status
      end

      it '#error? is false' do
        expect(subject).not_to be_error
      end

      it '#success? is false' do
        expect(subject).not_to be_success
      end

      it '#pending? is true' do
        expect(subject).to be_pending
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
soapy_bing-0.1.0 spec/soapy_bing/soap/response/report_status_spec.rb
soapy_bing-0.0.5 spec/soapy_bing/soap/response/report_status_spec.rb