File: builder.rb

package info (click to toggle)
ruby-protocol-http 0.55.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 840 kB
  • sloc: ruby: 6,904; makefile: 4
file content (44 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.

require "protocol/http/middleware"
require "protocol/http/middleware/builder"

describe Protocol::HTTP::Middleware::Builder do
	it "can make an app" do
		app = Protocol::HTTP::Middleware.build do
			run Protocol::HTTP::Middleware::HelloWorld
		end
		
		expect(app).to be_equal(Protocol::HTTP::Middleware::HelloWorld)
	end
	
	it "defaults to not found" do
		app = Protocol::HTTP::Middleware.build do
		end
		
		expect(app).to be_equal(Protocol::HTTP::Middleware::NotFound)
	end
	
	it "can instantiate middleware" do
		app = Protocol::HTTP::Middleware.build do
			use Protocol::HTTP::Middleware
		end
		
		expect(app).to be_a(Protocol::HTTP::Middleware)
	end
	
	it "provides the builder as an argument" do
		current_self = self
		
		app = Protocol::HTTP::Middleware.build do |builder|
			builder.use Protocol::HTTP::Middleware
			
			expect(self).to be_equal(current_self)
		end
		
		expect(app).to be_a(Protocol::HTTP::Middleware)
	end
end