File: utils_spec.rb

package info (click to toggle)
ruby-roadie 5.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 512 kB
  • sloc: ruby: 3,418; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 1,007 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
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

require "spec_helper"

module Roadie
  describe Utils, "path_is_absolute?" do
    RSpec::Matchers.define :be_absolute do
      match { |path| Utils.path_is_absolute?(path) }
    end

    it "detects absolute HTTP URLs" do
      expect("http://example.com").to be_absolute
      expect("https://example.com").to be_absolute
      expect("https://example.com/path?foo=bar").to be_absolute
    end

    it "detects absolute URLs without schemes" do
      expect("//example.com").to be_absolute
      expect("//").to be_absolute
    end

    it "detects relative URLs without hosts" do
      expect("path/to/me").not_to be_absolute
      expect("/path/to/me").not_to be_absolute
      expect("../../path").not_to be_absolute
      expect("/").not_to be_absolute
    end
  end

  describe Utils, "warn" do
    it "passes the message on to Kernel.warn" do
      expect(Kernel).to receive(:warn).with("Roadie: Hello from specs")
      Utils.warn "Hello from specs"
    end
  end
end