Sha256: c4457bf10be2ab9f29dddb9739191b235967dbf21097c2de387159de867cacff

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

RSpec.describe "scope options" do
  before { load "spec/fixtures/test_client.rb" }

  let(:params) { { subdomain: "europe", user: "andy", token: "foo", foo: 0 } }
  let(:client) { Test::Client.new(params) }
  let(:crm)    { client.crm(version: 4) }

  shared_examples :valid_client do |details = "properly"|
    it "[assigns scope options #{details}]" do
      expect(subject.options).to eq options
    end
  end

  it_behaves_like :valid_client, "with defined options" do
    subject { crm.users }
    let(:options) do
      { subdomain: "europe", user: "andy", token: "foo", version: 4 }
    end
  end

  it_behaves_like :valid_client, "with reloaded scope options" do
    subject { crm.users(version: 8) }
    let(:options) do
      { subdomain: "europe", user: "andy", token: "foo", version: 8 }
    end
  end

  it_behaves_like :valid_client, "with reloaded root options" do
    subject { crm.users(user: "leo") }
    let(:options) do
      { subdomain: "europe", user: "leo", token: "foo", version: 4 }
    end
  end

  context "when required options missed" do
    subject { client.crm }

    it "raises StandardError" do
      expect { subject }
        .to raise_error StandardError, /version/
    end
  end

  context "when some validation failed" do
    subject { crm.users(token: nil) }

    it "raises StandardError" do
      expect { subject }
        .to raise_error StandardError, /token/
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evil-client-3.0.4 spec/features/scope/options_spec.rb
evil-client-3.0.3 spec/features/scope/options_spec.rb
evil-client-3.0.2 spec/features/scope/options_spec.rb
evil-client-3.0.1 spec/features/scope/options_spec.rb
evil-client-3.0.0 spec/features/scope/options_spec.rb