File: rack_adapter_spec.rb

package info (click to toggle)
yard 0.9.38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,736 kB
  • sloc: ruby: 31,680; javascript: 7,658; makefile: 21
file content (21 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true
require File.dirname(__FILE__) + "/spec_helper"

RSpec.describe "YARD::Server::RackMiddleware" do
  before do
    begin; require 'rack'; rescue LoadError; pending "rack required for these tests" end
    @superapp = double(:superapp)
    @app = YARD::Server::RackMiddleware.new(@superapp, :libraries => {'foo' => [LibraryVersion.new('foo', nil)]})
  end

  after(:all) { YARD::Server::Adapter.shutdown }

  it "handles requests" do
    expect(@app.call(Rack::MockRequest.env_for('/'))[0]).to eq 200
  end

  it "passes up to the next middleware on 404" do
    expect(@superapp).to receive(:call).and_return([200, {}, ['OK']])
    expect(@app.call(Rack::MockRequest.env_for('/INVALID'))).to eq [200, {}, ['OK']]
  end
end