Sha256: 1adfa0a7b78b73cf72735a31311e01852ba6d0d9aa15c335609ef547244f3bf2

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

RSpec.describe PortalConnectors::SocialClient do
  def client
    @client ||= PortalConnectors::SocialClient.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(1)
        expect(data["receiver_email"]).to eq("test@example.com")
        expect(data["verify_status"]).to eq("pending")
      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/social_client_spec.rb
portal-connectors-0.58.39xb spec/lib/portal-connectors/social_client_spec.rb
portal-connectors-0.58.39xa spec/lib/portal-connectors/social_client_spec.rb
portal-connectors-0.58.39fj spec/lib/portal-connectors/social_client_spec.rb
portal-connectors-0.58.39fg spec/lib/portal-connectors/social_client_spec.rb
portal-connectors-0.58.38xn spec/lib/portal-connectors/social_client_spec.rb