Sha256: 49bbca594061e94d96ce68b58521674c6d05b6870423c21f6cf2e1a188bbd115

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

RSpec.describe PortalConnectors::AutomateClient do
  def client
    @client ||= PortalConnectors::AutomateClient.singleton
  end

  describe ".sign" do
    it "returns signature of request" do
      params = {
        receiver_email: "test@remest.info",
        content: "email content"
      }
      expect(client.sign(params)).to be_present
    end
  end

  describe "#submit_email_otp", :vcr do
    context "server response with error status" do
      it "returns error" do
        client = described_class.singleton

        params = {
          receiver_email: "test@example.com",
          content: ""
        }
        data, ok = client.submit_email_otp(params)
        expect(ok).to be_falsy
        expect(data["error"]).to eq("Content can't be blank")
      end
    end

    context "server response with success status" do
      it "returns submitted email_otp" do
        client = described_class.singleton
        content = <<~MESSAGE
          Ma OTP: 975104
        MESSAGE
        params = {
          content: content,
          receiver_email: "test@example.com"
        }
        data, ok = client.submit_email_otp(params)
        expect(ok).to be_truthy
        expect(data["id"]).to eq(6)
        expect(data["receiver_email"]).to eq("test@example.com")
        expect(data["content"]).to eq(content)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
portal-connectors-0.58.39xc spec/lib/portal-connectors/automate_client_spec.rb
portal-connectors-0.58.39xb spec/lib/portal-connectors/automate_client_spec.rb
portal-connectors-0.58.39xa spec/lib/portal-connectors/automate_client_spec.rb
portal-connectors-0.58.39fj spec/lib/portal-connectors/automate_client_spec.rb
portal-connectors-0.58.39fg spec/lib/portal-connectors/automate_client_spec.rb
portal-connectors-0.58.38xn spec/lib/portal-connectors/automate_client_spec.rb