Sha256: 5312595d3653f4682e7420c02ec8405658fb1ae4fbd2c44a4bd45731e4c91572

Contents?: true

Size: 1.27 KB

Versions: 6758

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe Ethon::Easy::Http::Options do
  let(:easy) { Ethon::Easy.new }
  let(:url) { "http://localhost:3001/" }
  let(:params) { nil }
  let(:form) { nil }
  let(:options) { described_class.new(url, {:params => params, :body => form}) }

  describe "#setup" do
    it "sets customrequest" do
      expect(easy).to receive(:customrequest=).with("OPTIONS")
      options.setup(easy)
    end

    it "sets url" do
      options.setup(easy)
      expect(easy.url).to eq(url)
    end

    context "when requesting" do
      let(:params) { {:a => "1&b=2"} }

      before do
        options.setup(easy)
        easy.perform
      end

      it "returns ok" do
        expect(easy.return_code).to eq(:ok)
      end

      it "is a options request" do
        expect(easy.response_body).to include('"REQUEST_METHOD":"OPTIONS"')
      end

      it "requests parameterized url" do
        expect(easy.effective_url).to eq("http://localhost:3001/?a=1%26b%3D2")
      end

      context "when url already contains params" do
        let(:url) { "http://localhost:3001/?query=here" }

        it "requests parameterized url" do
          expect(easy.effective_url).to eq("http://localhost:3001/?query=here&a=1%26b%3D2")
        end
      end
    end
  end
end

Version data entries

6,758 entries across 6,756 versions & 22 rubygems

Version Path
ory-client-0.0.1.alpha123 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha122 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha121 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha120 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha119 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha118 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha117 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha116 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha115 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-keto-client-0.8.0.alpha2 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
cloudsmith-api-1.33.7 vendor/bundle/ruby/2.6.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha113 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha112 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha111 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha110 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha109 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
avalara_sdk-2.4.26 vendor/bundle/ruby/2.6.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-client-0.0.1.alpha108 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-oathkeeper-client-0.38.23.beta1 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb
ory-oathkeeper-client-0.38.22.beta1 vendor/bundle/ruby/2.5.0/gems/ethon-0.15.0/spec/ethon/easy/http/options_spec.rb