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
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
RSpec.describe Autoloaded::Warning do
|
4
|
+
before :each do
|
5
|
+
warning_module.io = io
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:warning_module) { described_class }
|
9
|
+
|
10
|
+
let(:io) { StringIO.new }
|
11
|
+
|
12
|
+
describe '.enable' do
|
13
|
+
describe 'simple form' do
|
14
|
+
describe 'with nil argument' do
|
15
|
+
specify('sets .enabled? as expected') {
|
16
|
+
warning_module.enable nil
|
17
|
+
expect(warning_module.enabled?).to eq(false)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'with false argument' do
|
22
|
+
specify('sets .enabled? as expected') {
|
23
|
+
warning_module.enable false
|
24
|
+
expect(warning_module.enabled?).to eq(false)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'with string argument' do
|
29
|
+
specify('sets .enabled? as expected') {
|
30
|
+
warning_module.enable 'foo'
|
31
|
+
expect(warning_module.enabled?).to eq(true)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'with true argument' do
|
36
|
+
specify('sets .enabled? as expected') {
|
37
|
+
warning_module.enable true
|
38
|
+
expect(warning_module.enabled?).to eq(true)
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
specify("returns #{Autoloaded::Warning.name}") {
|
43
|
+
expect(warning_module.enable('foo')).to eq(warning_module)
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'block form' do
|
48
|
+
specify('returns the result of the block') {
|
49
|
+
result = warning_module.enable('foo') do
|
50
|
+
:block_result
|
51
|
+
end
|
52
|
+
expect(result).to eq(:block_result)
|
53
|
+
}
|
54
|
+
|
55
|
+
describe 'if the block returns' do
|
56
|
+
specify('resets .enabled?') {
|
57
|
+
expect {
|
58
|
+
warning_module.enable(false) { }
|
59
|
+
}.not_to change { warning_module.enabled? }
|
60
|
+
expect {
|
61
|
+
warning_module.enable(true) { }
|
62
|
+
}.not_to change { warning_module.enabled? }
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'if the block raises an error' do
|
67
|
+
specify('resets .enabled?') {
|
68
|
+
expect {
|
69
|
+
begin
|
70
|
+
warning_module.enable(false) do
|
71
|
+
1 / 0
|
72
|
+
end
|
73
|
+
rescue ZeroDivisionError
|
74
|
+
end
|
75
|
+
}.not_to change { warning_module.enabled? }
|
76
|
+
expect {
|
77
|
+
begin
|
78
|
+
warning_module.enable(true) do
|
79
|
+
1 / 0
|
80
|
+
end
|
81
|
+
rescue ZeroDivisionError
|
82
|
+
end
|
83
|
+
}.not_to change { warning_module.enabled? }
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '.changing_autoload' do
|
90
|
+
before :each do
|
91
|
+
warning_module.enable true
|
92
|
+
warning_module.changing_autoload constant_name: :Foo,
|
93
|
+
old_source_filename: 'bar',
|
94
|
+
new_source_filename: 'baz',
|
95
|
+
host_source_location: 'qux.rb:123'
|
96
|
+
end
|
97
|
+
|
98
|
+
specify('writes the expected message to .io') {
|
99
|
+
expect(io.string).to eq(%Q(\e[33m*** \e[7m WARNING \e[0m Existing autoload of \e[4mFoo\e[0m from "bar" is being overridden to autoload from "baz" -- avoid this warning by using an \e[4monly\e[0m or an \e[4mexcept\e[0m specification in the block at qux.rb:123\n))
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '.existing_constant' do
|
104
|
+
before :each do
|
105
|
+
warning_module.enable true
|
106
|
+
warning_module.existing_constant constant_name: :Foo,
|
107
|
+
source_filename: 'bar',
|
108
|
+
host_source_location: 'baz.rb:123'
|
109
|
+
end
|
110
|
+
|
111
|
+
specify('writes the expected message to .io') {
|
112
|
+
expect(io.string).to eq(%Q(\e[33m*** \e[7m WARNING \e[0m Existing definition of \e[4mFoo\e[0m obviates autoloading from "bar" -- avoid this warning by using an \e[4monly\e[0m or an \e[4mexcept\e[0m specification in the block at baz.rb:123\n))
|
113
|
+
}
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
RSpec.shared_examples_for "an #{Autoloaded.name} macro" do |macro|
|
2
|
+
before :each do
|
3
|
+
allow(autoloader_class).to receive(:new).and_return(autoloader)
|
4
|
+
allow_any_instance_of(autoloader_class).to receive(:autoload!)
|
5
|
+
end
|
6
|
+
|
7
|
+
let(:autoloaded_module) { Autoloaded }
|
8
|
+
|
9
|
+
let(:autoloader) { autoloader_class.new binding }
|
10
|
+
|
11
|
+
let(:autoloader_class) { autoloaded_module::Autoloader }
|
12
|
+
|
13
|
+
specify("yields an #{Autoloaded::Autoloader.name}") {
|
14
|
+
autoloaded_module.send macro do |autoloaded|
|
15
|
+
expect(autoloaded).to equal(autoloader)
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
specify("calls #{Autoloaded::Autoloader.name}#autoload!") {
|
20
|
+
expect(autoloader).to receive(:autoload!)
|
21
|
+
autoloaded_module.send macro do |autoloaded|
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
data/spec/autoloaded_spec.rb
CHANGED
@@ -1,138 +1,320 @@
|
|
1
|
-
require '
|
1
|
+
require 'autoloaded_macro_sharedspec'
|
2
2
|
require 'matchers'
|
3
|
+
require 'stringio'
|
3
4
|
|
4
5
|
RSpec.describe Autoloaded do
|
5
|
-
|
6
|
-
class << self
|
7
|
-
alias_method :define_constant, :define_constants
|
8
|
-
end
|
9
|
-
end
|
6
|
+
let(:autoloaded_module) { described_class }
|
10
7
|
|
11
|
-
|
12
|
-
fork
|
13
|
-
rescue NotImplementedError => e
|
14
|
-
pending "[pending because #{e.message}]"
|
15
|
-
else
|
16
|
-
describe 'not extending a namespace' do
|
17
|
-
subject(:source_file) { 'spec/fixtures/not_autoloaded.rb' }
|
8
|
+
let(:warning_module) { autoloaded_module::Warning }
|
18
9
|
|
19
|
-
|
10
|
+
describe '.class' do
|
11
|
+
it_behaves_like "an #{Autoloaded.name} macro", :class
|
12
|
+
end
|
20
13
|
|
21
|
-
|
14
|
+
describe '.module' do
|
15
|
+
it_behaves_like "an #{Autoloaded.name} macro", :module
|
16
|
+
end
|
22
17
|
|
23
|
-
|
18
|
+
describe '.warn' do
|
19
|
+
describe 'simple form' do
|
20
|
+
before :each do
|
21
|
+
allow(warning_module).to receive(:enable).
|
22
|
+
and_return(:warning_enable_result)
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
specify("delegates to #{Autoloaded::Warning.name}.enable") {
|
26
|
+
expect(warning_module).to receive(:enable).
|
27
|
+
with('foo').
|
28
|
+
and_return(:warning_enable_result)
|
29
|
+
autoloaded_module.warn 'foo'
|
28
30
|
}
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
specify("returns #{Autoloaded.name}") {
|
33
|
+
expect(autoloaded_module.warn('foo')).to eq(autoloaded_module)
|
32
34
|
}
|
33
35
|
end
|
34
36
|
|
35
|
-
describe '
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
describe 'block form' do
|
38
|
+
specify("delegates to #{Autoloaded::Warning.name}.enable") {
|
39
|
+
expect(warning_module).to receive(:enable).
|
40
|
+
with('foo').
|
41
|
+
and_yield.
|
42
|
+
and_return(:warning_enable_result)
|
43
|
+
result = autoloaded_module.warn('foo') do
|
44
|
+
:block_result
|
45
|
+
end
|
46
|
+
expect(result).to eq(:warning_enable_result)
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
40
50
|
|
41
|
-
|
51
|
+
describe '.warn?' do
|
52
|
+
specify("delegates to #{Autoloaded::Warning.name}.enabled?") {
|
53
|
+
expect(warning_module).to receive(:enabled?).
|
54
|
+
and_return(:warning_enabled_result)
|
55
|
+
expect(autoloaded_module.warn?).to eq(:warning_enabled_result)
|
56
|
+
}
|
57
|
+
end
|
42
58
|
|
43
|
-
|
44
|
-
|
45
|
-
|
59
|
+
describe 'integration' do
|
60
|
+
before :each do
|
61
|
+
class << self
|
62
|
+
alias_method :define_constant, :define_constants
|
63
|
+
end
|
64
|
+
end
|
46
65
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
66
|
+
begin
|
67
|
+
fork do
|
68
|
+
# The codeclimate-test-reporter RubyGem uses Kernel#at_exit to hook the
|
69
|
+
# end of test/spec runs for sending coverage statistics to their web
|
70
|
+
# service. We need to skip that hook in this process fork because this is
|
71
|
+
# not the end of a test/spec run, only of a process fork.
|
72
|
+
exit!(true) if ENV['CODECLIMATE_REPO_TOKEN']
|
73
|
+
end
|
74
|
+
rescue NotImplementedError => e
|
75
|
+
pending "[pending because #{e.message}]"
|
76
|
+
else
|
77
|
+
describe 'not extending a namespace' do
|
78
|
+
subject(:source_file) { 'spec/fixtures/not_autoloaded.rb' }
|
51
79
|
|
52
|
-
it {
|
53
|
-
is_expected.not_to define_constant('AutoloadedWithConventionalFilename::NONEXISTENT')
|
54
|
-
}
|
80
|
+
it { is_expected.to define_constant(:NotAutoloaded) }
|
55
81
|
|
56
|
-
it {
|
57
|
-
|
58
|
-
|
59
|
-
}
|
82
|
+
it { is_expected.to define_constant('NotAutoloaded::OldSchoolAutoload') }
|
83
|
+
|
84
|
+
it { is_expected.not_to define_constant('NotAutoloaded::Nested') }
|
60
85
|
|
61
86
|
it {
|
62
|
-
is_expected.to set_up_autoload_for_constant('
|
63
|
-
|
64
|
-
'fixtures/autoloaded_with_conventional_filename/N-est-ed',
|
65
|
-
'fixtures/autoloaded_with_conventional_filename/nest_ed')
|
87
|
+
is_expected.to set_up_autoload_for_constant('NotAutoloaded::OldSchoolAutoload').
|
88
|
+
from_file('fixtures/not_autoloaded/old_school_autoload')
|
66
89
|
}
|
67
90
|
|
68
91
|
it {
|
69
|
-
is_expected.not_to set_up_autoload_for_constant('
|
92
|
+
is_expected.not_to set_up_autoload_for_constant('NotAutoloaded::Nested')
|
70
93
|
}
|
71
94
|
end
|
72
95
|
|
73
|
-
describe '
|
74
|
-
|
75
|
-
|
76
|
-
|
96
|
+
describe 'extending a namespace whose constituent source files include' do
|
97
|
+
describe 'a conventional source filename used for autoloading' do
|
98
|
+
subject(:source_file) {
|
99
|
+
'spec/fixtures/autoloaded_with_conventional_filename.rb'
|
100
|
+
}
|
77
101
|
|
78
|
-
|
102
|
+
it {
|
103
|
+
is_expected.to define_constant(:AutoloadedWithConventionalFilename)
|
104
|
+
}
|
79
105
|
|
80
|
-
|
81
|
-
|
82
|
-
|
106
|
+
it {
|
107
|
+
is_expected.to define_constant('AutoloadedWithConventionalFilename::OldSchoolAutoload')
|
108
|
+
}
|
83
109
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
110
|
+
it {
|
111
|
+
is_expected.to define_constant('AutoloadedWithConventionalFilename::Nested')
|
112
|
+
}
|
88
113
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
}
|
114
|
+
it {
|
115
|
+
is_expected.not_to define_constant('AutoloadedWithConventionalFilename::NONEXISTENT')
|
116
|
+
}
|
93
117
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
118
|
+
it {
|
119
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithConventionalFilename::OldSchoolAutoload').
|
120
|
+
from_file('fixtures/autoloaded_with_conventional_filename/old_school_autoload')
|
121
|
+
}
|
98
122
|
|
99
|
-
|
100
|
-
|
101
|
-
|
123
|
+
it {
|
124
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithConventionalFilename::Nested').
|
125
|
+
from_file('fixtures/autoloaded_with_conventional_filename/nested')
|
126
|
+
}
|
127
|
+
|
128
|
+
it {
|
129
|
+
is_expected.not_to set_up_autoload_for_constant('AutoloadedWithConventionalFilename::NONEXISTENT')
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'unconventional source filenames' do
|
134
|
+
subject(:source_file) {
|
135
|
+
'spec/fixtures/autoloaded_with_unconventional_filename.rb'
|
136
|
+
}
|
137
|
+
|
138
|
+
it {
|
139
|
+
is_expected.to define_constant(:AutoloadedWithUnconventionalFilename)
|
140
|
+
}
|
141
|
+
|
142
|
+
it {
|
143
|
+
is_expected.to define_constant('AutoloadedWithUnconventionalFilename::OldSchoolAutoload')
|
144
|
+
}
|
145
|
+
|
146
|
+
it {
|
147
|
+
is_expected.to define_constants('AutoloadedWithUnconventionalFilename::Nested1',
|
148
|
+
'AutoloadedWithUnconventionalFilename::Nested2')
|
149
|
+
}
|
150
|
+
|
151
|
+
it {
|
152
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilename::OldSchoolAutoload').
|
153
|
+
from_file('fixtures/autoloaded_with_unconventional_filename/old_school_autoload')
|
154
|
+
}
|
155
|
+
|
156
|
+
it {
|
157
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilename::Nested1').
|
158
|
+
from_file('fixtures/autoloaded_with_unconventional_filename/N-est-ed')
|
159
|
+
}
|
160
|
+
|
161
|
+
it {
|
162
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilename::Nested2').
|
163
|
+
from_file('fixtures/autoloaded_with_unconventional_filename/N-est-ed')
|
164
|
+
}
|
165
|
+
|
166
|
+
it {
|
167
|
+
is_expected.not_to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilename::NONEXISTENT')
|
168
|
+
}
|
169
|
+
end
|
102
170
|
end
|
171
|
+
end
|
103
172
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
173
|
+
describe 'old API' do
|
174
|
+
before :each do
|
175
|
+
autoloaded_module::Deprecation.io = StringIO.new
|
176
|
+
end
|
108
177
|
|
109
|
-
|
110
|
-
|
111
|
-
|
178
|
+
after :each do
|
179
|
+
autoloaded_module::Deprecation.io = nil
|
180
|
+
end
|
112
181
|
|
113
|
-
|
114
|
-
|
115
|
-
|
182
|
+
begin
|
183
|
+
fork do
|
184
|
+
# The codeclimate-test-reporter RubyGem uses Kernel#at_exit to hook the
|
185
|
+
# end of test/spec runs for sending coverage statistics to their web
|
186
|
+
# service. We need to skip that hook in this process fork because this is
|
187
|
+
# not the end of a test/spec run, only of a process fork.
|
188
|
+
exit!(true) if ENV['CODECLIMATE_REPO_TOKEN']
|
189
|
+
end
|
190
|
+
rescue NotImplementedError => e
|
191
|
+
pending "[pending because #{e.message}]"
|
192
|
+
else
|
193
|
+
describe 'not extending a namespace' do
|
194
|
+
subject(:source_file) { 'spec/fixtures/old_api/not_autoloaded.rb' }
|
116
195
|
|
117
|
-
|
118
|
-
is_expected.to define_constants('AutoloadedWithUnconventionalFilenames::Nested').
|
119
|
-
dynamically
|
120
|
-
}
|
196
|
+
it { is_expected.to define_constant(:NotAutoloaded) }
|
121
197
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
198
|
+
it {
|
199
|
+
is_expected.to define_constant('NotAutoloaded::OldSchoolAutoload')
|
200
|
+
}
|
126
201
|
|
127
|
-
|
128
|
-
is_expected.to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilenames::Nested').
|
129
|
-
from_files('fixtures/autoloaded_with_unconventional_filenames/N-est-ed',
|
130
|
-
'fixtures/autoloaded_with_unconventional_filenames/nest_ed')
|
131
|
-
}
|
202
|
+
it { is_expected.not_to define_constant('NotAutoloaded::Nested') }
|
132
203
|
|
133
|
-
|
134
|
-
|
135
|
-
|
204
|
+
it {
|
205
|
+
is_expected.to set_up_autoload_for_constant('NotAutoloaded::OldSchoolAutoload').
|
206
|
+
from_file('fixtures/old_api/not_autoloaded/old_school_autoload')
|
207
|
+
}
|
208
|
+
|
209
|
+
it {
|
210
|
+
is_expected.not_to set_up_autoload_for_constant('NotAutoloaded::Nested')
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
describe 'extending a namespace whose constituent source files include' do
|
215
|
+
describe 'a conventional source filename used for autoloading' do
|
216
|
+
subject(:source_file) {
|
217
|
+
'spec/fixtures/old_api/autoloaded_with_conventional_filename.rb'
|
218
|
+
}
|
219
|
+
|
220
|
+
it {
|
221
|
+
is_expected.to define_constant(:AutoloadedWithConventionalFilename)
|
222
|
+
}
|
223
|
+
|
224
|
+
it {
|
225
|
+
is_expected.to define_constant('AutoloadedWithConventionalFilename::OldSchoolAutoload')
|
226
|
+
}
|
227
|
+
|
228
|
+
it {
|
229
|
+
is_expected.to define_constant('AutoloadedWithConventionalFilename::Nested')
|
230
|
+
}
|
231
|
+
|
232
|
+
it {
|
233
|
+
is_expected.not_to define_constant('AutoloadedWithConventionalFilename::NONEXISTENT')
|
234
|
+
}
|
235
|
+
|
236
|
+
it {
|
237
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithConventionalFilename::OldSchoolAutoload').
|
238
|
+
from_file('fixtures/old_api/autoloaded_with_conventional_filename/old_school_autoload')
|
239
|
+
}
|
240
|
+
|
241
|
+
it {
|
242
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithConventionalFilename::Nested').
|
243
|
+
from_files('fixtures/old_api/autoloaded_with_conventional_filename/nested',
|
244
|
+
'fixtures/old_api/autoloaded_with_conventional_filename/N-est-ed',
|
245
|
+
'fixtures/old_api/autoloaded_with_conventional_filename/nest_ed')
|
246
|
+
}
|
247
|
+
|
248
|
+
it {
|
249
|
+
is_expected.not_to set_up_autoload_for_constant('AutoloadedWithConventionalFilename::NONEXISTENT')
|
250
|
+
}
|
251
|
+
end
|
252
|
+
|
253
|
+
describe 'a conventional source filename only' do
|
254
|
+
subject(:source_file) {
|
255
|
+
'spec/fixtures/old_api/autoloaded_with_conventional_filename_only.rb'
|
256
|
+
}
|
257
|
+
|
258
|
+
it {
|
259
|
+
is_expected.to define_constant(:AutoloadedWithConventionalFilenameOnly)
|
260
|
+
}
|
261
|
+
|
262
|
+
it {
|
263
|
+
is_expected.to define_constant('AutoloadedWithConventionalFilenameOnly::OldSchoolAutoload')
|
264
|
+
}
|
265
|
+
|
266
|
+
it {
|
267
|
+
is_expected.to define_constant('AutoloadedWithConventionalFilenameOnly::Nested')
|
268
|
+
}
|
269
|
+
|
270
|
+
it {
|
271
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithConventionalFilenameOnly::OldSchoolAutoload').
|
272
|
+
from_file('fixtures/old_api/autoloaded_with_conventional_filename_only/old_school_autoload')
|
273
|
+
}
|
274
|
+
|
275
|
+
it {
|
276
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithConventionalFilenameOnly::Nested').
|
277
|
+
from_file('fixtures/old_api/autoloaded_with_conventional_filename_only/nested')
|
278
|
+
}
|
279
|
+
|
280
|
+
it {
|
281
|
+
is_expected.not_to set_up_autoload_for_constant('AutoloadedWithConventionalFilenameOnly::NONEXISTENT')
|
282
|
+
}
|
283
|
+
end
|
284
|
+
|
285
|
+
describe 'unconventional source filenames' do
|
286
|
+
subject(:source_file) {
|
287
|
+
'spec/fixtures/old_api/autoloaded_with_unconventional_filenames.rb'
|
288
|
+
}
|
289
|
+
|
290
|
+
it {
|
291
|
+
is_expected.to define_constant(:AutoloadedWithUnconventionalFilenames)
|
292
|
+
}
|
293
|
+
|
294
|
+
it {
|
295
|
+
is_expected.to define_constant('AutoloadedWithUnconventionalFilenames::OldSchoolAutoload')
|
296
|
+
}
|
297
|
+
|
298
|
+
it {
|
299
|
+
is_expected.to define_constants('AutoloadedWithUnconventionalFilenames::Nested')
|
300
|
+
}
|
301
|
+
|
302
|
+
it {
|
303
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilenames::OldSchoolAutoload').
|
304
|
+
from_file('fixtures/old_api/autoloaded_with_unconventional_filenames/old_school_autoload')
|
305
|
+
}
|
306
|
+
|
307
|
+
it {
|
308
|
+
is_expected.to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilenames::Nested').
|
309
|
+
from_files('fixtures/old_api/autoloaded_with_unconventional_filenames/N-est-ed',
|
310
|
+
'fixtures/old_api/autoloaded_with_unconventional_filenames/nest_ed')
|
311
|
+
}
|
312
|
+
|
313
|
+
it {
|
314
|
+
is_expected.not_to set_up_autoload_for_constant('AutoloadedWithUnconventionalFilenames::NONEXISTENT')
|
315
|
+
}
|
316
|
+
end
|
317
|
+
end
|
136
318
|
end
|
137
319
|
end
|
138
320
|
end
|