Sha256: 05632fafe4d912f2ed2087f4eb78e631754c56af17973e2f8db3f982789fd77a

Contents?: true

Size: 1.1 KB

Versions: 6846

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Typhoeus::Hydra::Stubbable do
  let(:base_url) { "localhost:3001" }
  let(:request) { Typhoeus::Request.new(base_url) }
  let(:response) { Typhoeus::Response.new }
  let(:hydra) { Typhoeus::Hydra.new }

  before { Typhoeus.stub(base_url).and_return(response) }

  describe "#add" do
    it "checks expectations" do
      hydra.add(request)
    end

    context "when expectation found" do
      it "calls on_headers callbacks" do
        canary = :not_called
        request.on_headers do
          canary = :called
        end
        hydra.add(request)
        hydra.run
        expect(canary).to eq(:called)
      end

      it "calls on_body callbacks" do
        canary = :not_called
        request.on_body do
          canary = :called
        end
        hydra.add(request)
        hydra.run
        expect(canary).to eq(:called)
      end

      it "finishes response" do
        expect(request).to receive(:finish)
        hydra.add(request)
      end

      it "is a mock" do
        hydra.add(request)
        expect(request.response.mock).to be(true)
      end
    end
  end
end

Version data entries

6,846 entries across 6,843 versions & 28 rubygems

Version Path
ory-client-0.0.1.alpha54 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha53 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha52 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha51 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha50 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha49 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha48 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha47 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha46 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha45 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha44 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha43 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha42 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha41 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha40 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha39 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha38 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha37 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-client-0.0.1.alpha36 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb
ory-kratos-client-0.8.2.alpha1 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/spec/typhoeus/hydra/stubbable_spec.rb