From e405613685394932bba0d1ffa8bb8fc484e4279c Mon Sep 17 00:00:00 2001 From: Bobby McDonald Date: Thu, 10 Dec 2020 13:04:28 -0500 Subject: [PATCH] Freeze omniauth in test to verify thread safety --- Gemfile | 1 + spec/helper.rb | 1 + spec/omniauth/builder_spec.rb | 9 +++------ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index b0581c0..9f08f3a 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ group :test do gem 'rack-test' gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18] gem 'rspec', '~> 3.5' + gem 'rack-freeze' gem 'rubocop', '>= 0.58.2', '< 0.69.0', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24] gem 'simplecov-lcov' gem 'tins', '~> 1.13', :platforms => %i[jruby_18 jruby_19 ruby_19] diff --git a/spec/helper.rb b/spec/helper.rb index bca865c..6583992 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -20,6 +20,7 @@ end require 'rspec' require 'rack/test' +require 'rack/freeze' require 'omniauth' require 'omniauth/test' diff --git a/spec/omniauth/builder_spec.rb b/spec/omniauth/builder_spec.rb index d2dd3a9..da6a2e4 100644 --- a/spec/omniauth/builder_spec.rb +++ b/spec/omniauth/builder_spec.rb @@ -121,14 +121,11 @@ describe OmniAuth::Builder do describe '#call' do it 'passes env to to_app.call' do - app = lambda { |_env| [200, {}, []] } + app = lambda { |env| [200, {}, env['CUSTOM_ENV_VALUE']] } builder = OmniAuth::Builder.new(app) - env = {'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/some/path'} - allow(app).to receive(:call).and_call_original + env = {'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/some/path', 'CUSTOM_ENV_VALUE' => 'VALUE'} - builder.call(env) - - expect(app).to have_received(:call).with(env) + expect(builder.call(env)).to eq([200, {}, 'VALUE']) end end