Sha256: 0d44c42f3b4efc2f1197903a18822aa2d7bdd6d81a4e0352adb25cc58b243c48

Contents?: true

Size: 719 Bytes

Versions: 4

Compression:

Stored size: 719 Bytes

Contents

shared_examples_for 'a cached connection method' do

  let(:connection){
    meth = connection_method
    Class.new(Alf::Adapter::Connection) do
      define_method(meth) do |name|
        raise unless @seen.nil?
        @seen = [ name ]
      end
    end.new(nil)
  }
  let(:cached)     { Alf::Adapter::Connection::SchemaCached.new(connection) }
  let(:relvar_name){ :a_relvar_name }
  let(:expected)   { [relvar_name]  }

  def subject
    cached.send(connection_method, relvar_name)
  end

  it 'delegates the call to the connection' do
    subject.should eq(expected)
  end

  it 'does caches the result' do
    subject.should eq(expected)
    subject.should eq(expected)
    subject.should eq(expected)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-adapter/shared_examples/a_cached_connection_method.rb
alf-core-0.14.0 spec/unit/alf-adapter/shared_examples/a_cached_connection_method.rb
alf-core-0.13.1 spec/unit/alf-adapter/shared_examples/a_cached_connection_method.rb
alf-core-0.13.0 spec/unit/alf-adapter/shared_examples/a_cached_connection_method.rb