Sha256: 4172771bfec519d749a6c223e9beaa2a454b9bb6cd6e28f72441a92a6920fa3a

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

RSpec.describe SmsAero, "#check_tariff" do
  let(:settings) { { user: "LOGIN", password: "PASSWORD" } }
  let(:client)   { described_class.new(settings) }
  let(:params)   { {} }
  let(:answer) { { result: "accepted", reason: { "Direct channel": "1.75" } } }

  before  { stub_request(:any, //).to_return(body: answer.to_json) }
  subject { client.check_tariff(params) }

  context "using ssl via POST:" do
    let(:url) do
      "https://gate.smsaero.ru/checktarif?" \
      "answer=json&" \
      "password=319f4d26e3c536b5dd871bb2c52e3178&" \
      "user=LOGIN"
    end

    it "sends a request" do
      subject
      expect(a_request(:post, url)).to have_been_made
    end

    it "returns statuses" do
      expect(subject.result).to eq "accepted"
      expect(subject.tariff.to_h).to eq direct: 1.75
    end
  end

  context "via GET:" do
    let(:url) do
      "https://gate.smsaero.ru/checktarif?" \
      "answer=json&" \
      "password=319f4d26e3c536b5dd871bb2c52e3178&" \
      "user=LOGIN"
    end

    before { settings[:use_post] = false }

    it "sends a request" do
      subject
      expect(a_request(:get, url)).to have_been_made
    end
  end

  context "not using ssl:" do
    let(:url) do
      "http://gate.smsaero.ru/checktarif?" \
      "answer=json&" \
      "password=319f4d26e3c536b5dd871bb2c52e3178&" \
      "user=LOGIN"
    end

    before { settings[:use_ssl] = false }

    it "sends a request" do
      subject
      expect(a_request(:post, url)).to have_been_made
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sms_aero-0.2.0 spec/operations/check_tariff_spec.rb
sms_aero-0.1.3 spec/operations/check_tariff_spec.rb
sms_aero-0.1.2 spec/operations/check_tariff_spec.rb
sms_aero-0.1.1 spec/operations/check_tariff_spec.rb
sms_aero-0.1.0 spec/operations/check_tariff_spec.rb