diff options
Diffstat (limited to 'spec/support/shared_contexts/lib/gitlab/middleware')
-rw-r--r-- | spec/support/shared_contexts/lib/gitlab/middleware/with_a_mocked_gitlab_instance_shared_context.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/lib/gitlab/middleware/with_a_mocked_gitlab_instance_shared_context.rb b/spec/support/shared_contexts/lib/gitlab/middleware/with_a_mocked_gitlab_instance_shared_context.rb new file mode 100644 index 00000000000..3830b89f1ff --- /dev/null +++ b/spec/support/shared_contexts/lib/gitlab/middleware/with_a_mocked_gitlab_instance_shared_context.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +RSpec.shared_context 'with a mocked GitLab instance' do + let(:rack_stack) do + rack = Rack::Builder.new do + use ActionDispatch::Session::CacheStore + use ActionDispatch::Flash + end + + rack.run(subject) + rack.to_app + end + + let(:observe_env) do + Module.new do + attr_reader :env + + def call(env) + @env = env + super + end + end + end + + let(:request) { Rack::MockRequest.new(rack_stack) } + + subject do + described_class.new(fake_app).tap do |app| + app.extend(observe_env) + end + end +end |