Sha256: 0bdedd0f8c5d54bcfe60e53c2198ecb9c105a790465fade9da96e220473b161b

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Zoom::Actions::Webinar do
  let(:zc) { zoom_client }
  let(:args) { { id: 'webinar_id',
                 first_name: 'Zoomie',
                 last_name: 'Userton',
                 email: 'foo@bar.com' } }

  describe '#webinar_registrant_add' do
    before :each do
      stub_request(
        :post,
        zoom_url("/webinars/#{args[:id]}/registrants")
      ).to_return(status: 201, body: json_response('webinar', 'registrant', 'add'))
    end

    it "requires a 'id' argument" do
      expect { zc.webinar_registrant_add(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
    end

    it "requires a 'first_name' argument" do
      expect { zc.webinar_registrant_add(filter_key(args, :first_name)) }.to raise_error(Zoom::ParameterMissing, [:first_name].to_s)
    end

    it "requires a 'last_name' argument" do
      expect { zc.webinar_registrant_add(filter_key(args, :last_name)) }.to raise_error(Zoom::ParameterMissing, [:last_name].to_s)
    end

    it "requires a 'email' argument" do
      expect { zc.webinar_registrant_add(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s)
    end

    it 'returns an Hash' do
      expect(zc.webinar_registrant_add(args)).to be_kind_of(Hash)
    end

    it 'returns a "join_url"' do
      res = zc.webinar_registrant_add(args)
      expect(res['join_url']).not_to be nil
    end
  end

  describe '#webinar_registrant_add!' do
    before :each do
      stub_request(
        :post,
        zoom_url("/webinars/#{args[:id]}/registrants")
      ).to_return(status: 404, body: json_response('error', 'validation'))
    end

    it 'raises Zoom::Error exception' do
      expect {
        zc.webinar_registrant_add!(args)
      }.to raise_error(Zoom::Error)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zoom_rb-0.8.1 spec/lib/zoom/actions/webinar/registrants/add_spec.rb