-
Notifications
You must be signed in to change notification settings - Fork 791
/
Copy pathtest_uri_tar.rb
68 lines (58 loc) · 2.92 KB
/
test_uri_tar.rb
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
# frozen_string_literal: true
require 'sprockets_test'
class TestURITar < Sprockets::TestCase
def setup
@fake_env = Class.new do
include Sprockets::PathUtils
attr_accessor :root
end.new
end
test "works with nix" do
skip "Only runs on nix" if File::ALT_SEPARATOR
uri = "/Sites/sprockets/test/fixtures/paths/application.css?type=text/css"
@fake_env.root = "/Different/path"
tar = Sprockets::URITar.new(uri, @fake_env)
assert_equal uri, tar.expand
assert_equal uri, tar.compress
assert_equal uri, tar.compressed_path
uri = "file:///Sites/sprockets/test/fixtures/paths/application.css?type=text/css"
@fake_env.root = "/Sites/sprockets"
tar = Sprockets::URITar.new(uri, @fake_env)
assert_equal uri, tar.expand
assert_equal Sprockets::URITar.new(tar.compress, @fake_env).expand, uri
assert_equal "test/fixtures/paths/application.css?type=text/css", tar.compressed_path
assert_equal "file://test/fixtures/paths/application.css?type=text/css", tar.compress
assert_equal Sprockets::URITar.new(tar.compress, @fake_env).compress, tar.compress
assert_equal Sprockets::URITar.new(tar.expand, @fake_env).compress, tar.compress
uri = "/Sites/sprockets/test/fixtures/paths/application.css?type=text/css"
@fake_env.root = "/Sites/sprockets"
tar = Sprockets::URITar.new(uri, @fake_env)
assert_equal uri, tar.expand
assert_equal "test/fixtures/paths/application.css?type=text/css", tar.compressed_path
assert_equal "test/fixtures/paths/application.css?type=text/css", tar.compress
end
test "works with windows" do
skip "Only runs on windows" unless File::ALT_SEPARATOR
uri = "C:/Sites/sprockets/test/fixtures/paths/application.css?type=text/css"
@fake_env.root = "C:/Different/path"
tar = Sprockets::URITar.new(uri, @fake_env)
assert_equal uri, tar.expand
assert_equal uri, tar.compress
assert_equal uri, tar.compressed_path
uri = "file:///C:/Sites/sprockets/test/fixtures/paths/application.css?type=text/css"
@fake_env.root = "C:/Sites/sprockets"
tar = Sprockets::URITar.new(uri, @fake_env)
assert_equal uri, tar.expand
assert_equal Sprockets::URITar.new(tar.compress, @fake_env).expand, uri
assert_equal "test/fixtures/paths/application.css?type=text/css", tar.compressed_path
assert_equal "file://test/fixtures/paths/application.css?type=text/css", tar.compress
assert_equal Sprockets::URITar.new(tar.compress, @fake_env).compress, tar.compress
assert_equal Sprockets::URITar.new(tar.expand, @fake_env).compress, tar.compress
uri = "C:/Sites/sprockets/test/fixtures/paths/application.css?type=text/css"
@fake_env.root = "C:/Sites/sprockets"
tar = Sprockets::URITar.new(uri, @fake_env)
assert_equal uri, tar.expand
assert_equal "test/fixtures/paths/application.css?type=text/css", tar.compressed_path
assert_equal "test/fixtures/paths/application.css?type=text/css", tar.compress
end
end