shared_connection_pool_spec.rb 635 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe ConnectionPool::SharedConnectionPool do
  4. subject { described_class.new(size: 5, timeout: 5) { |site| mini_connection_class.new(site) } }
  5. let(:mini_connection_class) do
  6. Class.new do
  7. attr_reader :site
  8. def initialize(site)
  9. @site = site
  10. end
  11. end
  12. end
  13. describe '#with' do
  14. it 'runs a block with a connection' do
  15. block_run = false
  16. subject.with('foo') do |connection|
  17. expect(connection).to be_a mini_connection_class
  18. block_run = true
  19. end
  20. expect(block_run).to be true
  21. end
  22. end
  23. end