autoloaded 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/History.md +4 -0
- data/README.md +411 -60
- data/autoloaded.gemspec +19 -14
- data/lib/autoloaded.rb +104 -91
- data/lib/autoloaded/autoloader.rb +260 -0
- data/lib/autoloaded/compatibility/refine_and_using.rb +2 -0
- data/lib/autoloaded/constant.rb +5 -2
- data/lib/autoloaded/deprecation.rb +50 -0
- data/lib/autoloaded/inflection.rb +71 -0
- data/lib/autoloaded/load_pathed_directory.rb +112 -0
- data/lib/autoloaded/refine.rb +7 -1
- data/lib/autoloaded/refine/string.rb +7 -0
- data/lib/autoloaded/refine/string/to_source_filename.rb +12 -0
- data/lib/autoloaded/specification.rb +97 -0
- data/lib/autoloaded/specifications.rb +66 -0
- data/lib/autoloaded/version.rb +3 -1
- data/lib/autoloaded/warning.rb +125 -0
- data/spec/autoloaded/autoloader_spec.rb +469 -0
- data/spec/autoloaded/constant_spec.rb +0 -2
- data/spec/autoloaded/deprecation_spec.rb +23 -0
- data/spec/autoloaded/inflection_spec.rb +30 -0
- data/spec/autoloaded/load_pathed_directory_spec.rb +120 -0
- data/spec/autoloaded/refine/string/to_source_filename_spec.rb +0 -2
- data/spec/autoloaded/specification_spec.rb +98 -0
- data/spec/autoloaded/specifications_spec.rb +191 -0
- data/spec/autoloaded/version_spec.rb +0 -2
- data/spec/autoloaded/warning_spec.rb +115 -0
- data/spec/autoloaded_macro_sharedspec.rb +24 -0
- data/spec/autoloaded_spec.rb +277 -95
- data/spec/fixtures/autoloaded_with_conventional_filename.rb +3 -1
- data/spec/fixtures/autoloaded_with_conventional_filename/nested.rb +12 -1
- data/spec/fixtures/autoloaded_with_conventional_filename/nested/doubly_nested.rb +9 -0
- data/spec/fixtures/autoloaded_with_unconventional_filename.rb +12 -0
- data/spec/fixtures/autoloaded_with_unconventional_filename/N-est-ed.rb +7 -0
- data/spec/fixtures/autoloaded_with_unconventional_filename/nest_ed.rb +1 -0
- data/spec/fixtures/autoloaded_with_unconventional_filename/old_school_autoload.rb +5 -0
- data/spec/fixtures/not_autoloaded/nested.rb +1 -0
- data/spec/fixtures/old_api/autoloaded_with_conventional_filename.rb +10 -0
- data/spec/fixtures/old_api/autoloaded_with_conventional_filename/N-est-ed.rb +1 -0
- data/spec/fixtures/old_api/autoloaded_with_conventional_filename/nest_ed.rb +1 -0
- data/spec/fixtures/old_api/autoloaded_with_conventional_filename/nested.rb +5 -0
- data/spec/fixtures/old_api/autoloaded_with_conventional_filename/old_school_autoload.rb +5 -0
- data/spec/fixtures/{autoloaded_with_conventional_filename_only.rb → old_api/autoloaded_with_conventional_filename_only.rb} +1 -1
- data/spec/fixtures/{autoloaded_with_conventional_filename_only → old_api/autoloaded_with_conventional_filename_only}/nested.rb +0 -0
- data/spec/fixtures/{autoloaded_with_conventional_filename_only → old_api/autoloaded_with_conventional_filename_only}/old_school_autoload.rb +0 -0
- data/spec/fixtures/{autoloaded_with_unconventional_filenames.rb → old_api/autoloaded_with_unconventional_filenames.rb} +1 -1
- data/spec/fixtures/{autoloaded_with_unconventional_filenames → old_api/autoloaded_with_unconventional_filenames}/N-est-ed.rb +0 -0
- data/spec/fixtures/{autoloaded_with_unconventional_filenames → old_api/autoloaded_with_unconventional_filenames}/nest_ed.rb +0 -0
- data/spec/fixtures/{autoloaded_with_unconventional_filenames → old_api/autoloaded_with_unconventional_filenames}/old_school_autoload.rb +0 -0
- data/spec/fixtures/old_api/not_autoloaded.rb +6 -0
- data/spec/fixtures/old_api/not_autoloaded/nested.rb +1 -0
- data/spec/fixtures/old_api/not_autoloaded/old_school_autoload.rb +5 -0
- data/spec/matchers.rb +4 -33
- data/spec/spec_helper.rb +2 -0
- metadata +95 -41
data/lib/autoloaded/version.rb
CHANGED
@@ -0,0 +1,125 @@
|
|
1
|
+
module Autoloaded; end
|
2
|
+
|
3
|
+
# Prints warning messages to _stderr_.
|
4
|
+
#
|
5
|
+
# @since 1.3
|
6
|
+
#
|
7
|
+
# @api private
|
8
|
+
module Autoloaded::Warning
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
# Sets the warning stream.
|
13
|
+
#
|
14
|
+
# @param [IO] value a new value for #io
|
15
|
+
attr_writer :io
|
16
|
+
|
17
|
+
# The warning stream. Defaults to +$stderr+.
|
18
|
+
#
|
19
|
+
# @return [IO] the warning stream
|
20
|
+
def io
|
21
|
+
@io || $stderr
|
22
|
+
end
|
23
|
+
|
24
|
+
# Prints a warning message to _#io_ concerning an existing autoloaded
|
25
|
+
# constant for which the autoloaded source file is being changed.
|
26
|
+
#
|
27
|
+
# @param [Symbol] constant_name the name of the constant
|
28
|
+
# @param [String] old_source_filename the name of the existing autoloaded
|
29
|
+
# source file
|
30
|
+
# @param [String] new_source_filename the name of the new autoloaded source
|
31
|
+
# file
|
32
|
+
# @param [String] host_source_location the file and line number of the source
|
33
|
+
# establishing autoloading
|
34
|
+
#
|
35
|
+
# @return [Module] _Warning_
|
36
|
+
def changing_autoload(constant_name: raise(::ArgumentError,
|
37
|
+
'missing keyword: constant_name'),
|
38
|
+
old_source_filename: raise(::ArgumentError,
|
39
|
+
'missing keyword: old_source_filename'),
|
40
|
+
new_source_filename: raise(::ArgumentError,
|
41
|
+
'missing keyword: new_source_filename'),
|
42
|
+
host_source_location: raise(::ArgumentError,
|
43
|
+
'missing keyword: host_source_location'))
|
44
|
+
message = "Existing autoload of \e[4m#{constant_name}\e[0m from " +
|
45
|
+
"#{old_source_filename.inspect} is being overridden to " +
|
46
|
+
"autoload from #{new_source_filename.inspect} -- avoid this " +
|
47
|
+
"warning by using an \e[4monly\e[0m or an \e[4mexcept\e[0m " +
|
48
|
+
"specification in the block at #{host_source_location}"
|
49
|
+
warn message
|
50
|
+
end
|
51
|
+
|
52
|
+
# Enables or disables warning messages depending on the specified _enabling_
|
53
|
+
# argument.
|
54
|
+
#
|
55
|
+
# @param [Object] enabling disables warnings if +nil+ or +false+
|
56
|
+
#
|
57
|
+
# @yield if a block is given, the value of _#enabled?_ is reset after the
|
58
|
+
# block is called
|
59
|
+
#
|
60
|
+
# @return if a block is given, the result of calling the block
|
61
|
+
# @return [Module] if a block is not given, _Warning_
|
62
|
+
#
|
63
|
+
# @see .enabled?
|
64
|
+
def enable(enabling)
|
65
|
+
previous_value = @disabled
|
66
|
+
@disabled = not!(enabling)
|
67
|
+
if block_given?
|
68
|
+
begin
|
69
|
+
return yield
|
70
|
+
ensure
|
71
|
+
@disabled = previous_value
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
78
|
+
# Indicates whether warning messages are enabled or disabled.
|
79
|
+
#
|
80
|
+
# @return [true] if warning messages are enabled
|
81
|
+
# @return [false] if warning messages are enabled
|
82
|
+
#
|
83
|
+
# @see .enable
|
84
|
+
def enabled?
|
85
|
+
not! @disabled
|
86
|
+
end
|
87
|
+
|
88
|
+
# Prints a warning message to _#io_ concerning a defined constant for which
|
89
|
+
# autoloading is being established.
|
90
|
+
#
|
91
|
+
# @param [Symbol] constant_name the name of the constant
|
92
|
+
# @param [String] source_filename the name of the autoloaded source file
|
93
|
+
# @param [String] host_source_location the file and line number of the source
|
94
|
+
# establishing autoloading
|
95
|
+
#
|
96
|
+
# @return [Module] _Warning_
|
97
|
+
def existing_constant(constant_name: raise(::ArgumentError,
|
98
|
+
'missing keyword: constant_name'),
|
99
|
+
source_filename: raise(::ArgumentError,
|
100
|
+
'missing keyword: source_filename'),
|
101
|
+
host_source_location: raise(::ArgumentError,
|
102
|
+
'missing keyword: host_source_location'))
|
103
|
+
message = "Existing definition of \e[4m#{constant_name}\e[0m obviates " +
|
104
|
+
"autoloading from #{source_filename.inspect} -- avoid this " +
|
105
|
+
"warning by using an \e[4monly\e[0m or an \e[4mexcept\e[0m " +
|
106
|
+
"specification in the block at #{host_source_location}"
|
107
|
+
warn message
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def not!(value)
|
113
|
+
value.nil? || (value == false)
|
114
|
+
end
|
115
|
+
|
116
|
+
def warn(message)
|
117
|
+
warning = "\e[33m*** \e[7m WARNING \e[0m #{message}"
|
118
|
+
io.puts(warning) if enabled?
|
119
|
+
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,469 @@
|
|
1
|
+
RSpec.describe Autoloaded::Autoloader do
|
2
|
+
subject(:autoloader) { autoloader_class.new host_binding }
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
allow(specifications_class).to receive(:new).and_return(specifications)
|
6
|
+
allow(inflector_class).to receive(:to_constant_name).
|
7
|
+
and_return(:FromInflection1,
|
8
|
+
:FromInflection2,
|
9
|
+
:FromInflection3,
|
10
|
+
:FromInflection4)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:autoloader_class) { described_class }
|
14
|
+
|
15
|
+
let(:host_binding) { self.class.class_eval 'binding', __FILE__, __LINE__ }
|
16
|
+
|
17
|
+
let(:directory_class) { Autoloaded::LoadPathedDirectory }
|
18
|
+
|
19
|
+
let(:specifications) { specifications_class.new }
|
20
|
+
|
21
|
+
let(:specifications_class) { Autoloaded::Specifications }
|
22
|
+
|
23
|
+
let(:specification_class) { Autoloaded::Specification }
|
24
|
+
|
25
|
+
let(:inflector_class) { Autoloaded::Inflection }
|
26
|
+
|
27
|
+
describe '.new' do
|
28
|
+
describe 'with nil argument' do
|
29
|
+
specify {
|
30
|
+
expect { autoloader_class.new nil }.to raise_error(ArgumentError,
|
31
|
+
"can't be nil")
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#from' do
|
37
|
+
subject(:from) { autoloader.from }
|
38
|
+
|
39
|
+
describe 'has expected default value' do
|
40
|
+
specify { is_expected.to eq(__FILE__.gsub(/\.rb$/, '')) }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'rejects relative path argument' do
|
44
|
+
specify {
|
45
|
+
expect {
|
46
|
+
autoloader.from 'a/relative/path'
|
47
|
+
}.to raise_error(ArgumentError, "can't be relative")
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'operates as attribute reader and writer' do
|
52
|
+
specify {
|
53
|
+
autoloader.from '/an/absolute/path'
|
54
|
+
is_expected.to eq('/an/absolute/path')
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#except' do
|
60
|
+
specify("delegates to #{Autoloaded::Specifications.name}#except") {
|
61
|
+
expect(specifications.except).to be_empty
|
62
|
+
autoloader.except 'foo'
|
63
|
+
expect(specifications.except).to contain_exactly(specification_class.new('foo'))
|
64
|
+
}
|
65
|
+
|
66
|
+
describe 'where #only is specified' do
|
67
|
+
before :each do
|
68
|
+
autoloader.only :Foo
|
69
|
+
end
|
70
|
+
|
71
|
+
specify {
|
72
|
+
expect { autoloader.except :Bar }.to raise_error(RuntimeError,
|
73
|
+
"can't specify `except' when `only' is already specified")
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#only' do
|
79
|
+
specify("delegates to #{Autoloaded::Specifications.name}#only") {
|
80
|
+
expect(specifications.only).to be_empty
|
81
|
+
autoloader.only 'foo'
|
82
|
+
expect(specifications.only).to contain_exactly(specification_class.new('foo'))
|
83
|
+
}
|
84
|
+
|
85
|
+
describe 'where #except is specified' do
|
86
|
+
before :each do
|
87
|
+
autoloader.except :Foo
|
88
|
+
end
|
89
|
+
|
90
|
+
specify {
|
91
|
+
expect { autoloader.only :Bar }.to raise_error(RuntimeError,
|
92
|
+
"can't specify `only' when `except' is already specified")
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#with' do
|
98
|
+
specify("delegates to #{Autoloaded::Specifications.name}#with") {
|
99
|
+
expect(specifications.with).to be_empty
|
100
|
+
autoloader.with 'foo'
|
101
|
+
expect(specifications.with).to contain_exactly(specification_class.new('foo'))
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#autoload!' do
|
106
|
+
before :each do
|
107
|
+
allow_any_instance_of(directory_class).to receive(:closest_ruby_load_path).
|
108
|
+
and_return('/foo')
|
109
|
+
allow(directory_class).to receive(:new).and_return(directory)
|
110
|
+
allow(directory).to receive(:each_source_filename)
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:directory) { directory_class.new '/foo' }
|
114
|
+
|
115
|
+
describe 'where #from is' do
|
116
|
+
describe 'not specified' do
|
117
|
+
describe "initializes #{Autoloaded::LoadPathedDirectory.name} with computed value" do
|
118
|
+
specify {
|
119
|
+
expect(directory_class).to receive(:new).
|
120
|
+
with(__FILE__.gsub(/\.rb$/, '')).
|
121
|
+
and_return(directory)
|
122
|
+
autoloader.autoload!
|
123
|
+
}
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe 'specified' do
|
128
|
+
before :each do
|
129
|
+
autoloader.from directory.path
|
130
|
+
allow(specifications).to receive(:except).
|
131
|
+
and_return(except_specifications)
|
132
|
+
allow(specifications).to receive(:only).
|
133
|
+
and_return(only_specifications)
|
134
|
+
allow(specifications).to receive(:with).
|
135
|
+
and_return(with_specifications)
|
136
|
+
end
|
137
|
+
|
138
|
+
let(:except_specifications) { [] }
|
139
|
+
|
140
|
+
let(:except_specification) { specification_class.new }
|
141
|
+
|
142
|
+
let(:only_specifications) { [] }
|
143
|
+
|
144
|
+
let(:only_specification) { specification_class.new }
|
145
|
+
|
146
|
+
let(:with_specifications) { [] }
|
147
|
+
|
148
|
+
let(:with_specification) { specification_class.new }
|
149
|
+
|
150
|
+
describe 'where no source files are found' do
|
151
|
+
specify {
|
152
|
+
expect(Kernel).not_to receive(:eval)
|
153
|
+
autoloader.autoload!
|
154
|
+
}
|
155
|
+
|
156
|
+
specify { expect(autoloader.autoload!).to be_empty }
|
157
|
+
end
|
158
|
+
|
159
|
+
describe 'where a source file is found' do
|
160
|
+
before :each do
|
161
|
+
allow(directory).to receive(:each_source_filename).
|
162
|
+
and_yield('from_each_source_filename')
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'and no specifications are provided' do
|
166
|
+
specify {
|
167
|
+
expect(Kernel).to receive(:eval).
|
168
|
+
with('autoload? :FromInflection1',
|
169
|
+
# host_binding,
|
170
|
+
# kind_of(String),
|
171
|
+
# kind_of(Numeric)).
|
172
|
+
host_binding).
|
173
|
+
ordered
|
174
|
+
expect(Kernel).to receive(:eval).
|
175
|
+
with('constants.include? :FromInflection1',
|
176
|
+
# host_binding,
|
177
|
+
# kind_of(String),
|
178
|
+
# kind_of(Numeric)).
|
179
|
+
host_binding).
|
180
|
+
ordered
|
181
|
+
expect(Kernel).to receive(:eval).
|
182
|
+
with('autoload :FromInflection1, "from_each_source_filename"',
|
183
|
+
# host_binding,
|
184
|
+
# kind_of(String),
|
185
|
+
# kind_of(Numeric)).
|
186
|
+
host_binding).
|
187
|
+
ordered
|
188
|
+
autoloader.autoload!
|
189
|
+
}
|
190
|
+
|
191
|
+
specify {
|
192
|
+
expect(autoloader.autoload!).to eq([[:FromInflection1,
|
193
|
+
'from_each_source_filename']])
|
194
|
+
}
|
195
|
+
end
|
196
|
+
|
197
|
+
describe "and a `with' specification is provided" do
|
198
|
+
before :each do
|
199
|
+
allow(with_specification).to receive(:match).and_return(:FromWith)
|
200
|
+
end
|
201
|
+
|
202
|
+
let(:with_specifications) { [with_specification] }
|
203
|
+
|
204
|
+
specify {
|
205
|
+
expect(Kernel).to receive(:eval).
|
206
|
+
with('autoload? :FromWith',
|
207
|
+
# host_binding,
|
208
|
+
# kind_of(String),
|
209
|
+
# kind_of(Numeric)).
|
210
|
+
host_binding).
|
211
|
+
ordered
|
212
|
+
expect(Kernel).to receive(:eval).
|
213
|
+
with('constants.include? :FromWith',
|
214
|
+
# host_binding,
|
215
|
+
# kind_of(String),
|
216
|
+
# kind_of(Numeric)).
|
217
|
+
host_binding).
|
218
|
+
ordered
|
219
|
+
expect(Kernel).to receive(:eval).
|
220
|
+
with('autoload :FromWith, "from_each_source_filename"',
|
221
|
+
# host_binding,
|
222
|
+
# kind_of(String),
|
223
|
+
# kind_of(Numeric))
|
224
|
+
host_binding).
|
225
|
+
ordered
|
226
|
+
autoloader.autoload!
|
227
|
+
}
|
228
|
+
|
229
|
+
specify {
|
230
|
+
expect(autoloader.autoload!).to eq([[:FromWith,
|
231
|
+
'from_each_source_filename']])
|
232
|
+
}
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "and an `only' specification is provided" do
|
236
|
+
before :each do
|
237
|
+
allow(only_specification).to receive(:match).and_return(:FromOnly)
|
238
|
+
end
|
239
|
+
|
240
|
+
let(:only_specifications) { [only_specification] }
|
241
|
+
|
242
|
+
specify {
|
243
|
+
expect(Kernel).to receive(:eval).
|
244
|
+
with('autoload? :FromOnly',
|
245
|
+
# host_binding,
|
246
|
+
# kind_of(String),
|
247
|
+
# kind_of(Numeric)).
|
248
|
+
host_binding).
|
249
|
+
ordered
|
250
|
+
expect(Kernel).to receive(:eval).
|
251
|
+
with('constants.include? :FromOnly',
|
252
|
+
# host_binding,
|
253
|
+
# kind_of(String),
|
254
|
+
# kind_of(Numeric)).
|
255
|
+
host_binding).
|
256
|
+
ordered
|
257
|
+
expect(Kernel).to receive(:eval).
|
258
|
+
with('autoload :FromOnly, "from_each_source_filename"',
|
259
|
+
# host_binding,
|
260
|
+
# kind_of(String),
|
261
|
+
# kind_of(Numeric)).
|
262
|
+
host_binding).
|
263
|
+
ordered
|
264
|
+
autoloader.autoload!
|
265
|
+
}
|
266
|
+
|
267
|
+
specify { expect(autoloader.autoload!).to eq([[:FromOnly,
|
268
|
+
'from_each_source_filename']]) }
|
269
|
+
end
|
270
|
+
|
271
|
+
describe "and both `with' and `only' specifications are provided" do
|
272
|
+
before :each do
|
273
|
+
allow(with_specification).to receive(:match).and_return(:FromWith)
|
274
|
+
allow(only_specification).to receive(:match).and_return(:FromOnly)
|
275
|
+
end
|
276
|
+
|
277
|
+
let(:with_specifications) { [with_specification] }
|
278
|
+
|
279
|
+
let(:only_specifications) { [only_specification] }
|
280
|
+
|
281
|
+
specify {
|
282
|
+
expect(Kernel).to receive(:eval).
|
283
|
+
with('autoload? :FromWith',
|
284
|
+
# host_binding,
|
285
|
+
# kind_of(String),
|
286
|
+
# kind_of(Numeric)).
|
287
|
+
host_binding).
|
288
|
+
ordered
|
289
|
+
expect(Kernel).to receive(:eval).
|
290
|
+
with('constants.include? :FromWith',
|
291
|
+
# host_binding,
|
292
|
+
# kind_of(String),
|
293
|
+
# kind_of(Numeric)).
|
294
|
+
host_binding).
|
295
|
+
ordered
|
296
|
+
expect(Kernel).to receive(:eval).
|
297
|
+
with('autoload :FromWith, "from_each_source_filename"',
|
298
|
+
# host_binding,
|
299
|
+
# kind_of(String),
|
300
|
+
# kind_of(Numeric)).
|
301
|
+
host_binding).
|
302
|
+
ordered
|
303
|
+
autoloader.autoload!
|
304
|
+
}
|
305
|
+
|
306
|
+
specify { expect(autoloader.autoload!).to eq([[:FromWith,
|
307
|
+
'from_each_source_filename']]) }
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe 'where multiple source files are found' do
|
312
|
+
before :each do
|
313
|
+
allow(directory).to receive(:each_source_filename).
|
314
|
+
and_yield('from_each_source_filename1').
|
315
|
+
and_yield('from_each_source_filename2').
|
316
|
+
and_yield('from_each_source_filename3')
|
317
|
+
end
|
318
|
+
|
319
|
+
describe 'and no specifications are provided' do
|
320
|
+
specify {
|
321
|
+
expect(Kernel).to receive(:eval).
|
322
|
+
with('autoload? :FromInflection1',
|
323
|
+
# host_binding,
|
324
|
+
# kind_of(String),
|
325
|
+
# kind_of(Numeric)).
|
326
|
+
host_binding).
|
327
|
+
ordered
|
328
|
+
expect(Kernel).to receive(:eval).
|
329
|
+
with('constants.include? :FromInflection1',
|
330
|
+
# host_binding,
|
331
|
+
# kind_of(String),
|
332
|
+
# kind_of(Numeric)).
|
333
|
+
host_binding).
|
334
|
+
ordered
|
335
|
+
expect(Kernel).to receive(:eval).
|
336
|
+
with('autoload :FromInflection1, "from_each_source_filename1"',
|
337
|
+
# host_binding,
|
338
|
+
# kind_of(String),
|
339
|
+
# kind_of(Numeric)).
|
340
|
+
host_binding).
|
341
|
+
ordered
|
342
|
+
expect(Kernel).to receive(:eval).
|
343
|
+
with('autoload? :FromInflection2',
|
344
|
+
# host_binding,
|
345
|
+
# kind_of(String),
|
346
|
+
# kind_of(Numeric)).
|
347
|
+
host_binding).
|
348
|
+
ordered
|
349
|
+
expect(Kernel).to receive(:eval).
|
350
|
+
with('constants.include? :FromInflection2',
|
351
|
+
# host_binding,
|
352
|
+
# kind_of(String),
|
353
|
+
# kind_of(Numeric)).
|
354
|
+
host_binding).
|
355
|
+
ordered
|
356
|
+
expect(Kernel).to receive(:eval).
|
357
|
+
with('autoload :FromInflection2, "from_each_source_filename2"',
|
358
|
+
# host_binding,
|
359
|
+
# kind_of(String),
|
360
|
+
# kind_of(Numeric)).
|
361
|
+
host_binding).
|
362
|
+
ordered
|
363
|
+
expect(Kernel).to receive(:eval).
|
364
|
+
with('autoload? :FromInflection3',
|
365
|
+
# host_binding,
|
366
|
+
# kind_of(String),
|
367
|
+
# kind_of(Numeric)).
|
368
|
+
host_binding).
|
369
|
+
ordered
|
370
|
+
expect(Kernel).to receive(:eval).
|
371
|
+
with('constants.include? :FromInflection3',
|
372
|
+
# host_binding,
|
373
|
+
# kind_of(String),
|
374
|
+
# kind_of(Numeric)).
|
375
|
+
host_binding).
|
376
|
+
ordered
|
377
|
+
expect(Kernel).to receive(:eval).
|
378
|
+
with('autoload :FromInflection3, "from_each_source_filename3"',
|
379
|
+
# host_binding,
|
380
|
+
# kind_of(String),
|
381
|
+
# kind_of(Numeric)).
|
382
|
+
host_binding).
|
383
|
+
ordered
|
384
|
+
autoloader.autoload!
|
385
|
+
}
|
386
|
+
|
387
|
+
specify {
|
388
|
+
expect(autoloader.autoload!).to eq([[:FromInflection1,
|
389
|
+
'from_each_source_filename1'],
|
390
|
+
[:FromInflection2,
|
391
|
+
'from_each_source_filename2'],
|
392
|
+
[:FromInflection3,
|
393
|
+
'from_each_source_filename3']])
|
394
|
+
}
|
395
|
+
end
|
396
|
+
|
397
|
+
describe "and a matching `except' specification is provided" do
|
398
|
+
before :each do
|
399
|
+
allow(except_specification).to receive(:match).
|
400
|
+
with('from_each_source_filename1').
|
401
|
+
and_return(nil)
|
402
|
+
allow(except_specification).to receive(:match).
|
403
|
+
with('from_each_source_filename2').
|
404
|
+
and_return(:FromExcept)
|
405
|
+
allow(except_specification).to receive(:match).
|
406
|
+
with('from_each_source_filename3').
|
407
|
+
and_return(nil)
|
408
|
+
end
|
409
|
+
|
410
|
+
let(:except_specifications) { [except_specification] }
|
411
|
+
|
412
|
+
specify {
|
413
|
+
expect(Kernel).to receive(:eval).
|
414
|
+
with('autoload? :FromInflection1',
|
415
|
+
# host_binding,
|
416
|
+
# kind_of(String),
|
417
|
+
# kind_of(Numeric)).
|
418
|
+
host_binding).
|
419
|
+
ordered
|
420
|
+
expect(Kernel).to receive(:eval).
|
421
|
+
with('constants.include? :FromInflection1',
|
422
|
+
# host_binding,
|
423
|
+
# kind_of(String),
|
424
|
+
# kind_of(Numeric)).
|
425
|
+
host_binding).
|
426
|
+
ordered
|
427
|
+
expect(Kernel).to receive(:eval).
|
428
|
+
with('autoload :FromInflection1, "from_each_source_filename1"',
|
429
|
+
# host_binding,
|
430
|
+
# kind_of(String),
|
431
|
+
# kind_of(Numeric)).
|
432
|
+
host_binding).
|
433
|
+
ordered
|
434
|
+
expect(Kernel).to receive(:eval).
|
435
|
+
with('autoload? :FromInflection2',
|
436
|
+
# host_binding,
|
437
|
+
# kind_of(String),
|
438
|
+
# kind_of(Numeric)).
|
439
|
+
host_binding).
|
440
|
+
ordered
|
441
|
+
expect(Kernel).to receive(:eval).
|
442
|
+
with('constants.include? :FromInflection2',
|
443
|
+
# host_binding,
|
444
|
+
# kind_of(String),
|
445
|
+
# kind_of(Numeric)).
|
446
|
+
host_binding).
|
447
|
+
ordered
|
448
|
+
expect(Kernel).to receive(:eval).
|
449
|
+
with('autoload :FromInflection2, "from_each_source_filename3"',
|
450
|
+
# host_binding,
|
451
|
+
# kind_of(String),
|
452
|
+
# kind_of(Numeric)).
|
453
|
+
host_binding).
|
454
|
+
ordered
|
455
|
+
autoloader.autoload!
|
456
|
+
}
|
457
|
+
|
458
|
+
specify {
|
459
|
+
expect(autoloader.autoload!).to eq([[:FromInflection1,
|
460
|
+
'from_each_source_filename1'],
|
461
|
+
[:FromInflection2,
|
462
|
+
'from_each_source_filename3']])
|
463
|
+
}
|
464
|
+
end
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|