File: middleware_spec.rb

package info (click to toggle)
ruby-batch-loader 2.0.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 284 kB
  • sloc: ruby: 783; makefile: 6; sh: 4
file content (24 lines) | stat: -rw-r--r-- 554 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "spec_helper"

RSpec.describe BatchLoader::Middleware do
  describe '#call' do
    it 'returns the result from the app' do
      app = ->(_env) { 1 }
      middleware = BatchLoader::Middleware.new(app)

      expect(middleware.call(nil)).to eq(1)
    end

    it 'clears the Executor' do
      app = ->(_) { nil }
      middleware = BatchLoader::Middleware.new(app)
      BatchLoader::Executor.ensure_current

      expect {
        middleware.call(nil)
      }.to change {
        BatchLoader::Executor.current
      }.to(nil)
    end
  end
end