Sha256: 682798979d884f7b3720797f6523b4a7898b5408cba00d6d873e5cfa61dd8874
Contents?: true
Size: 1.95 KB
Versions: 25
Compression:
Stored size: 1.95 KB
Contents
require 'helper' RSpec.describe Flipper::Middleware::SetupEnv do context 'with flipper instance' do let(:app) do app = lambda do |env| [200, { 'Content-Type' => 'text/html' }, [env['flipper'].object_id.to_s]] end builder = Rack::Builder.new builder.use described_class, flipper builder.run app builder end it 'sets flipper in env' do get '/' expect(last_response.body).to eq(flipper.object_id.to_s) end end context 'with block that returns flipper instance' do let(:flipper_block) do -> { flipper } end let(:app) do app = lambda do |env| [200, { 'Content-Type' => 'text/html' }, [env['flipper'].object_id.to_s]] end builder = Rack::Builder.new builder.use described_class, flipper_block builder.run app builder end it 'sets flipper in env' do get '/' expect(last_response.body).to eq(flipper.object_id.to_s) end end context 'when env already has flipper setup' do let(:app) do app = lambda do |env| [200, { 'Content-Type' => 'text/html' }, [env['flipper'].object_id.to_s]] end builder = Rack::Builder.new builder.use described_class, flipper builder.run app builder end it 'leaves env flipper alone' do env_flipper = build_flipper get '/', {}, 'flipper' => env_flipper expect(last_response.body).to eq(env_flipper.object_id.to_s) end end context 'when flipper instance is nil' do let(:app) do app = lambda do |env| [200, { 'Content-Type' => 'text/html' }, [env['flipper'].object_id.to_s]] end builder = Rack::Builder.new builder.use described_class, nil builder.run app builder end it 'leaves env flipper alone' do env_flipper = build_flipper get '/', {}, 'flipper' => env_flipper expect(last_response.body).to eq(env_flipper.object_id.to_s) end end end
Version data entries
25 entries across 25 versions & 1 rubygems