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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2024-2025, by Samuel Williams.
require "protocol/http/header/priority"
describe Protocol::HTTP::Header::Priority do
let(:header) {subject.new(description)}
with "u=1, i" do
it "correctly parses priority header" do
expect(header).to have_attributes(
urgency: be == 1,
incremental?: be == true,
)
end
end
with "u=0" do
it "correctly parses priority header" do
expect(header).to have_attributes(
urgency: be == 0,
incremental?: be == false,
)
end
end
with "i" do
it "correctly parses incremental flag" do
expect(header).to have_attributes(
# Default urgency level is used:
urgency: be == 3,
incremental?: be == true,
)
end
end
with "u=6" do
it "correctly parses urgency level" do
expect(header).to have_attributes(
urgency: be == 6,
)
end
end
with "u=9, i" do
it "gracefully handles non-standard urgency levels" do
expect(header).to have_attributes(
# Non-standard value is preserved
urgency: be == 9,
incremental?: be == true,
)
end
end
with "u=2, u=5" do
it "prioritizes the last urgency directive" do
expect(header).to have_attributes(
urgency: be == 5,
)
end
end
with "#<<" do
let(:header) {subject.new}
it "can append values" do
header << "u=4"
expect(header).to have_attributes(
urgency: be == 4,
)
end
it "can append incremental flag" do
header << "i"
expect(header).to have_attributes(
incremental?: be == true,
)
end
end
end
|