Sha256: 09be943920f701811d3af4f0db0852941fb62e3623ad2a9169a3a91befc04a3e
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' require 'rack' class TestApp def call(env) state = {} [Nanika1, Nanika2].each do |model| r = model.with_readonly { model.connection.query_cache_enabled } w = model.with_writable { model.connection.query_cache_enabled } state[model.name] = { readonly: r, writable: r } end env[:state] = state :result end end RSpec.describe SwitchPoint::QueryCache do let(:app) do Rack::Builder.new do use SwitchPoint::QueryCache run TestApp.new end end describe '#call' do it 'enables query cache of all models' do env = {} expect(app.call(env)).to eq(:result) expect(env[:state]).to eq( 'Nanika1' => { readonly: true, writable: true }, 'Nanika2' => { readonly: true, writable: true }, ) end context 'when names are specified' do let(:app) do Rack::Builder.new do use SwitchPoint::QueryCache, [:main, :nanika1] run TestApp.new end end it 'enables query caches of specified models' do env = {} expect(app.call(env)).to eq(:result) expect(env[:state]).to eq( 'Nanika1' => { readonly: true, writable: true }, 'Nanika2' => { readonly: false, writable: false }, ) end end context 'when unknown name is specified' do let(:app) do Rack::Builder.new do use SwitchPoint::QueryCache, [:unknown] run TestApp.new end end it 'raises error' do expect { app.call({}) }.to raise_error(KeyError) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
switch_point-0.6.0 | spec/switch_point/query_cache_spec.rb |