This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
forked from sambroad/jasmine-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath_expander_spec.rb
138 lines (120 loc) · 3.25 KB
/
path_expander_spec.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
require 'spec_helper'
describe Jasmine::PathExpander do
it "returns absolute paths" do
dir_glob = lambda do |pattern|
case pattern
when 'some_base/src1*'
['some_base/src1.js', 'some_base/src15.js']
when 'some_base/src2*'
['some_base/src2.js']
else
raise "Unexpected pattern received: #{pattern}"
end
end
expanded_files = Jasmine::PathExpander.expand(
'some_base',
['src1*', 'src2*'],
dir_glob
)
expanded_files.should == [
File.join('some_base', 'src1.js'),
File.join('some_base', 'src15.js'),
File.join('some_base', 'src2.js')
]
end
it "uniqs files" do
dir_glob = lambda do |pattern|
case pattern
when 'some_base/src1*'
['some_base/src1.js', 'some_base/src15.js', 'some_base/src1.js']
when 'some_base/src2*'
['some_base/src2.js']
else
raise "Unexpected pattern received: #{pattern}"
end
end
expanded_files = Jasmine::PathExpander.expand(
'some_base',
['src1*', 'src2*'],
dir_glob
)
expanded_files.should == [
File.join('some_base', 'src1.js'),
File.join('some_base', 'src15.js'),
File.join('some_base', 'src2.js')
]
end
it "sorts files" do
dir_glob = lambda do |pattern|
case pattern
when 'some_base/src0*'
['some_base/src0.js']
when 'some_base/src1*'
['some_base/src1zzz.js', 'some_base/src1.js']
else
raise "Unexpected pattern received: #{pattern}"
end
end
expanded_files = Jasmine::PathExpander.expand(
'some_base',
['src1*', 'src0*'],
dir_glob
)
expanded_files.should == [
File.join('some_base', 'src1.js'),
File.join('some_base', 'src1zzz.js'),
File.join('some_base', 'src0.js')
]
end
it "supports negation of passed patterns" do
dir_glob = lambda do |pattern|
case pattern
when 'some_base/src1*'
['some_base/src1.js', 'some_base/src15.js']
when 'some_base/src1.js'
['some_base/src1.js']
when 'some_base/src2*'
['some_base/src2.js']
else
raise "Unexpected pattern received: #{pattern}"
end
end
expanded_files = Jasmine::PathExpander.expand(
'some_base',
['src1*', '!src1.js', 'src2*'],
dir_glob
)
expanded_files.should == [
File.join('some_base', 'src15.js'),
File.join('some_base', 'src2.js')
]
end
it "passes through files that are not found by the globber and are not negations and not globs" do
#this is designed to support asset pipeline files that aren't found.
dir_glob = lambda do |pattern|
[]
end
expanded_files = Jasmine::PathExpander.expand(
'some_base',
['src1*', '!src1.js', 'src2.js'],
dir_glob
)
expanded_files.should == [
File.join('some_base', 'src2.js')
]
end
it "passes through files that are not found by the globber and look like urls" do
#this is designed to support cdn files
dir_glob = lambda do |pattern|
[]
end
expanded_files = Jasmine::PathExpander.expand(
'some_base',
['http://www.google.com'],
dir_glob
)
expanded_files.should == [
'http://www.google.com'
]
end
end