Sha256: 291a003b3b719170064e89c8afad3faecdf4bd50d46a68590566620ef7ee5453

Contents?: true

Size: 1.63 KB

Versions: 6785

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Typhoeus::Request::Marshal do
  let(:base_url) { "localhost:3001" }
  let(:request) { Typhoeus::Request.new(base_url) }

  describe "#marshal_dump" do
    %w(on_complete on_success on_failure on_progress).each do |name|
      context "when #{name} handler" do
        before { request.instance_variable_set("@#{name}", Proc.new{}) }

        it "doesn't include @#{name}" do
          expect(request.send(:marshal_dump).map(&:first)).to_not include("@#{name}")
        end

        it "doesn't raise when dumped" do
          expect { Marshal.dump(request) }.to_not raise_error
        end

        context "when loading" do
          let(:loaded) { Marshal.load(Marshal.dump(request)) }

          it "includes base_url" do
            expect(loaded.base_url).to eq(request.base_url)
          end

          it "doesn't include #{name}" do
            expect(loaded.instance_variables).to_not include("@#{name}")
          end
        end
      end
    end

    context 'when run through hydra' do
      let(:options) { {} }
      let(:hydra) { Typhoeus::Hydra.new(options) }

      before(:each) do
        hydra.queue(request)
        hydra.run
      end

      it "doesn't include @hydra" do
        expect(request.send(:marshal_dump).map(&:first)).to_not include("@hydra")
      end

      context 'when loading' do
        let(:loaded) { Marshal.load(Marshal.dump(request)) }

        it "includes base_url" do
          expect(loaded.base_url).to eq(request.base_url)
        end

        it "doesn't include #{name}" do
          expect(loaded.instance_variables).to_not include("@hydra")
        end
      end
    end
  end
end

Version data entries

6,785 entries across 6,782 versions & 24 rubygems

Version Path
cybrid_api_bank_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_id_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_bank_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_id_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_bank_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_id_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_bank_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_id_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_bank_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_id_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_bank_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_id_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_bank_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb
cybrid_api_organization_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/request/marshal_spec.rb