about summary refs log tree commit diff
path: root/spec/lib/connection_pool/shared_connection_pool_spec.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-07-04 16:21:39 +0200
committerThibaut Girka <thib@sitedethib.com>2019-07-04 16:21:39 +0200
commit6ab84c12a7ebc68fb8ce9a6b8228b28ec06a2c0f (patch)
tree0f023e22bcb1ae01ce3fb4e43b771609493e4e65 /spec/lib/connection_pool/shared_connection_pool_spec.rb
parentc94966891af1ff456c6382595c07c2d68c57ec49 (diff)
parent99924f282f53593e670c70a38450a1c0e2d24c20 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'spec/lib/connection_pool/shared_connection_pool_spec.rb')
-rw-r--r--spec/lib/connection_pool/shared_connection_pool_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/connection_pool/shared_connection_pool_spec.rb b/spec/lib/connection_pool/shared_connection_pool_spec.rb
new file mode 100644
index 000000000..114464558
--- /dev/null
+++ b/spec/lib/connection_pool/shared_connection_pool_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe ConnectionPool::SharedConnectionPool do
+  class MiniConnection
+    attr_reader :site
+
+    def initialize(site)
+      @site = site
+    end
+  end
+
+  subject { described_class.new(size: 5, timeout: 5) { |site| MiniConnection.new(site) } }
+
+  describe '#with' do
+    it 'runs a block with a connection' do
+      block_run = false
+
+      subject.with('foo') do |connection|
+        expect(connection).to be_a MiniConnection
+        block_run = true
+      end
+
+      expect(block_run).to be true
+    end
+  end
+end