summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services/projects/urls_with_escaped_elements_shared_example.rb
blob: df8b1f91629e2397a04eda114fbadefc3d95e45b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

# Shared examples that test requests against URLs with escaped elements
#
RSpec.shared_examples "URLs containing escaped elements return expected status" do
  using RSpec::Parameterized::TableSyntax

  where(:url, :result_status) do
    "https://user:0a%23@test.example.com/project.git"                               | :success
    "https://git.example.com:1%2F%2F@source.developers.google.com/project.git"      | :success
    CGI.escape("git://localhost:1234/some-path?some-query=some-val\#@example.com/") | :error
    CGI.escape(CGI.escape("https://user:0a%23@test.example.com/project.git"))       | :error
  end

  with_them do
    it "returns expected status" do
      expect(result[:status]).to eq(result_status)
    end
  end
end