autoloaded 1.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +8 -4
  3. data/.rspec +1 -1
  4. data/.travis.yml +1 -15
  5. data/Gemfile +10 -11
  6. data/Guardfile +22 -21
  7. data/History.md +16 -40
  8. data/License.md +1 -1
  9. data/README.md +69 -79
  10. data/Rakefile +0 -4
  11. data/autoloaded.gemspec +37 -41
  12. data/lib/autoloaded/autoloader.rb +8 -31
  13. data/lib/autoloaded/deprecation.rb +20 -11
  14. data/lib/autoloaded/inflection.rb +9 -7
  15. data/lib/autoloaded/load_pathed_directory.rb +4 -2
  16. data/lib/autoloaded/specification.rb +0 -2
  17. data/lib/autoloaded/specifications.rb +10 -16
  18. data/lib/autoloaded/version.rb +1 -1
  19. data/lib/autoloaded/warning.rb +44 -26
  20. data/lib/autoloaded.rb +0 -40
  21. data/lib/tasks/lib_each.rake +3 -15
  22. data/lib/tasks/spec.rake +6 -3
  23. data/spec/autoloaded/autoloader_spec.rb +469 -0
  24. data/spec/autoloaded/inflection_spec.rb +30 -0
  25. data/spec/autoloaded/load_pathed_directory_spec.rb +120 -0
  26. data/spec/autoloaded/specification_spec.rb +98 -0
  27. data/spec/autoloaded/specifications_spec.rb +191 -0
  28. data/spec/autoloaded/version_spec.rb +3 -0
  29. data/spec/autoloaded/warning_spec.rb +115 -0
  30. data/spec/autoloaded_macro_sharedspec.rb +24 -0
  31. data/spec/autoloaded_spec.rb +173 -0
  32. data/spec/fixtures/autoloaded_with_conventional_filename/N-est-ed.rb +1 -0
  33. data/spec/fixtures/autoloaded_with_conventional_filename/nest_ed.rb +1 -0
  34. data/spec/fixtures/autoloaded_with_conventional_filename/nested/doubly_nested.rb +9 -0
  35. data/spec/fixtures/autoloaded_with_conventional_filename/nested.rb +16 -0
  36. data/spec/fixtures/autoloaded_with_conventional_filename/old_school_autoload.rb +5 -0
  37. data/spec/fixtures/autoloaded_with_conventional_filename.rb +12 -0
  38. data/spec/fixtures/autoloaded_with_unconventional_filename/N-est-ed.rb +7 -0
  39. data/spec/fixtures/autoloaded_with_unconventional_filename/nest_ed.rb +1 -0
  40. data/spec/fixtures/autoloaded_with_unconventional_filename/old_school_autoload.rb +5 -0
  41. data/spec/fixtures/autoloaded_with_unconventional_filename.rb +12 -0
  42. data/spec/fixtures/filenames/AFilename.rb +0 -0
  43. data/spec/fixtures/filenames/a-file-name.rb +0 -0
  44. data/spec/fixtures/filenames/a-filename.rb +0 -0
  45. data/spec/fixtures/filenames/a_file_name.rb +0 -0
  46. data/spec/fixtures/filenames/a_filename.rb +0 -0
  47. data/spec/fixtures/filenames/afile-name.rb +0 -0
  48. data/spec/fixtures/filenames/afile_name.rb +0 -0
  49. data/spec/fixtures/not_autoloaded/nested.rb +1 -0
  50. data/spec/fixtures/not_autoloaded/old_school_autoload.rb +5 -0
  51. data/spec/fixtures/not_autoloaded.rb +5 -0
  52. data/spec/matchers.rb +85 -0
  53. data/spec/spec_helper.rb +91 -0
  54. data/spec/support/util.rb +42 -0
  55. data/spec/support/without_side_effects.rb +37 -0
  56. metadata +86 -25
  57. data/bin/console +0 -10
  58. data/bin/setup +0 -8
  59. data/lib/autoloaded/compatibility/refine_and_using.rb +0 -19
  60. data/lib/autoloaded/constant.rb +0 -94
  61. data/lib/autoloaded/refine/string/to_source_filename.rb +0 -58
  62. data/lib/autoloaded/refine/string.rb +0 -20
  63. data/lib/autoloaded/refine.rb +0 -16
@@ -0,0 +1,98 @@
1
+ RSpec.describe Autoloaded::Specification do
2
+ before :each do
3
+ allow(inflector_class).to receive(:to_constant_name).
4
+ and_return(:FromInflection1,
5
+ :FromInflection2,
6
+ :FromInflection3)
7
+ end
8
+
9
+ subject(:specification) { specification_class.new(*elements) }
10
+
11
+ let(:specification_class) { described_class }
12
+
13
+ let(:inflector_class) { Autoloaded::Inflection }
14
+
15
+ specify("equals equivalent #{described_class.name}") {
16
+ expect(specification_class.new('foo')).to eq(specification_class.new('foo'))
17
+ }
18
+
19
+ specify("doesn't equal #{Object.name}") {
20
+ expect(specification_class.new('foo')).not_to eq(Object.new)
21
+ }
22
+
23
+ specify("doesn't equal #{described_class.name} with different #elements") {
24
+ expect(specification_class.new('foo')).not_to eq(specification_class.new('bar'))
25
+ }
26
+
27
+ describe 'with no elements' do
28
+ let(:elements) { [] }
29
+
30
+ specify { expect(specification.match('foo/bar')).to be_nil }
31
+ end
32
+
33
+ describe 'with one nonmatching element' do
34
+ let(:elements) { ['foo/bar'] }
35
+
36
+ specify { expect(specification.match('foo/baz')).to be_nil }
37
+ end
38
+
39
+ describe 'with one matching string element' do
40
+ let(:elements) { ['FOO/BAR'] }
41
+
42
+ specify { expect(specification.match('foo/bar')).to eq(:FromInflection1) }
43
+ end
44
+
45
+ describe 'with one matching symbol element' do
46
+ let(:elements) { [:FROMINFLECTION1] }
47
+
48
+ specify { expect(specification.match('foo/bar')).to eq(:FROMINFLECTION1) }
49
+ end
50
+
51
+ describe 'with two string elements, the second of which is matching' do
52
+ let(:elements) { %w(foo/bar baz/qux) }
53
+
54
+ specify { expect(specification.match('baz/qux')).to eq(:FromInflection1) }
55
+ end
56
+
57
+ describe 'with two symbol elements, the second of which is matching' do
58
+ let(:elements) { [:Foo, :FromInflection2] }
59
+
60
+ specify { expect(specification.match('baz/qux')).to eq(:FromInflection2) }
61
+ end
62
+
63
+ describe 'with a nonmatching hash element' do
64
+ let(:elements) { [{Foo: 'bar/baz'}] }
65
+
66
+ specify { expect(specification.match('bar/qux')).to be_nil }
67
+ end
68
+
69
+ describe 'with a hash element in which a key matches' do
70
+ let(:elements) { [{FromInflection1: 'bar/baz'}] }
71
+
72
+ specify { expect(specification.match('foo')).to eq('bar/baz') }
73
+ end
74
+
75
+ describe 'with a hash element in which a value matches' do
76
+ let(:elements) { [{Foo: 'bar/baz'}] }
77
+
78
+ specify { expect(specification.match('bar/baz')).to eq(:Foo) }
79
+ end
80
+
81
+ describe 'with a hash element in which an array key has a match' do
82
+ let(:elements) { [{[:Foo, :FromInflection2] => 'bar/baz'}] }
83
+
84
+ specify { expect(specification.match('qux')).to eq('bar/baz') }
85
+ end
86
+
87
+ describe 'with a hash element in which a an array value has a match' do
88
+ let(:elements) { [{Foo: %w(bar/baz qux/quux)}] }
89
+
90
+ specify { expect(specification.match('qux/quux')).to eq(:Foo) }
91
+ end
92
+
93
+ describe 'with a nonmatching string and a hash element in which an array key has a match' do
94
+ let(:elements) { ['foo', {[:Bar, :FromInflection2] => 'baz/qux'}] }
95
+
96
+ specify { expect(specification.match('quux')).to eq('baz/qux') }
97
+ end
98
+ end
@@ -0,0 +1,191 @@
1
+ RSpec.describe Autoloaded::Specifications do
2
+ subject(:specifications) { specifications_class.new }
3
+
4
+ let(:specifications_class) { described_class }
5
+
6
+ describe 'empty' do
7
+ describe '#except' do
8
+ subject(:except) { specifications.except }
9
+
10
+ specify { is_expected.to be_empty }
11
+ end
12
+
13
+ describe '#only' do
14
+ subject(:only) { specifications.only }
15
+
16
+ specify { is_expected.to be_empty }
17
+ end
18
+
19
+ describe '#with' do
20
+ subject(:with) { specifications.with }
21
+
22
+ specify { is_expected.to be_empty }
23
+ end
24
+
25
+ describe '#validate! :except' do
26
+ specify { expect { specifications.validate! :except }.not_to raise_error }
27
+ end
28
+
29
+ describe '#validate! :only' do
30
+ specify { expect { specifications.validate! :only }.not_to raise_error }
31
+ end
32
+
33
+ describe '#validate! :with' do
34
+ specify { expect { specifications.validate! :with }.not_to raise_error }
35
+ end
36
+ end
37
+
38
+ describe 'with #except' do
39
+ before :each do
40
+ specifications.except << :foo
41
+ end
42
+
43
+ describe '#except' do
44
+ subject(:except) { specifications.except }
45
+
46
+ specify { is_expected.to contain_exactly(:foo) }
47
+ end
48
+
49
+ describe '#only' do
50
+ subject(:only) { specifications.only }
51
+
52
+ specify { is_expected.to be_empty }
53
+ end
54
+
55
+ describe '#with' do
56
+ subject(:with) { specifications.with }
57
+
58
+ specify { is_expected.to be_empty }
59
+ end
60
+
61
+ describe '#validate! :except' do
62
+ specify { expect { specifications.validate! :except }.not_to raise_error }
63
+ end
64
+
65
+ describe '#validate! :only' do
66
+ specify { expect { specifications.validate! :only }.not_to raise_error }
67
+ end
68
+
69
+ describe '#validate! :with' do
70
+ specify { expect { specifications.validate! :with }.not_to raise_error }
71
+ end
72
+
73
+ describe 'and #only' do
74
+ before :each do
75
+ specifications.only << :bar
76
+ end
77
+
78
+ describe '#except' do
79
+ subject(:except) { specifications.except }
80
+
81
+ specify { is_expected.to contain_exactly(:foo) }
82
+ end
83
+
84
+ describe '#only' do
85
+ subject(:only) { specifications.only }
86
+
87
+ specify { is_expected.to contain_exactly(:bar) }
88
+ end
89
+
90
+ describe '#with' do
91
+ subject(:with) { specifications.with }
92
+
93
+ specify { is_expected.to be_empty }
94
+ end
95
+
96
+ describe '#validate! :except' do
97
+ specify {
98
+ expect {
99
+ specifications.validate! :except
100
+ }.to raise_error(RuntimeError,
101
+ "can't specify `except' when `only' is already specified")
102
+ }
103
+ end
104
+
105
+ describe '#validate! :only' do
106
+ specify {
107
+ expect {
108
+ specifications.validate! :only
109
+ }.to raise_error(RuntimeError,
110
+ "can't specify `only' when `except' is already specified")
111
+ }
112
+ end
113
+
114
+ describe '#validate! :with' do
115
+ specify { expect { specifications.validate! :with }.not_to raise_error }
116
+ end
117
+ end
118
+ end
119
+
120
+ describe 'with #only' do
121
+ before :each do
122
+ specifications.only << :foo
123
+ end
124
+
125
+ describe '#except' do
126
+ subject(:except) { specifications.except }
127
+
128
+ specify { is_expected.to be_empty }
129
+ end
130
+
131
+ describe '#only' do
132
+ subject(:only) { specifications.only }
133
+
134
+ specify { is_expected.to contain_exactly(:foo) }
135
+ end
136
+
137
+ describe '#with' do
138
+ subject(:with) { specifications.with }
139
+
140
+ specify { is_expected.to be_empty }
141
+ end
142
+
143
+ describe '#validate! :except' do
144
+ specify { expect { specifications.validate! :except }.not_to raise_error }
145
+ end
146
+
147
+ describe '#validate! :only' do
148
+ specify { expect { specifications.validate! :only }.not_to raise_error }
149
+ end
150
+
151
+ describe '#validate! :with' do
152
+ specify { expect { specifications.validate! :with }.not_to raise_error }
153
+ end
154
+ end
155
+
156
+ describe 'with #with' do
157
+ before :each do
158
+ specifications.with << :foo
159
+ end
160
+
161
+ describe '#except' do
162
+ subject(:except) { specifications.except }
163
+
164
+ specify { is_expected.to be_empty }
165
+ end
166
+
167
+ describe '#only' do
168
+ subject(:only) { specifications.only }
169
+
170
+ specify { is_expected.to be_empty }
171
+ end
172
+
173
+ describe '#with' do
174
+ subject(:with) { specifications.with }
175
+
176
+ specify { is_expected.to contain_exactly(:foo) }
177
+ end
178
+
179
+ describe '#validate! :except' do
180
+ specify { expect { specifications.validate! :except }.not_to raise_error }
181
+ end
182
+
183
+ describe '#validate! :only' do
184
+ specify { expect { specifications.validate! :only }.not_to raise_error }
185
+ end
186
+
187
+ describe '#validate! :with' do
188
+ specify { expect { specifications.validate! :with }.not_to raise_error }
189
+ end
190
+ end
191
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.describe "#{Autoloaded.name}::VERSION" do
2
+ specify { expect(Autoloaded::VERSION).to match( /^\d+\.\d+\.\d+/ ) }
3
+ end
@@ -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
@@ -0,0 +1,173 @@
1
+ require 'autoloaded_macro_sharedspec'
2
+ require 'matchers'
3
+ require 'stringio'
4
+
5
+ RSpec.describe Autoloaded do
6
+ let(:autoloaded_module) { described_class }
7
+
8
+ let(:warning_module) { autoloaded_module::Warning }
9
+
10
+ describe '.class' do
11
+ it_behaves_like "an #{Autoloaded.name} macro", :class
12
+ end
13
+
14
+ describe '.module' do
15
+ it_behaves_like "an #{Autoloaded.name} macro", :module
16
+ end
17
+
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
+
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'
30
+ }
31
+
32
+ specify("returns #{Autoloaded.name}") {
33
+ expect(autoloaded_module.warn('foo')).to eq(autoloaded_module)
34
+ }
35
+ end
36
+
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
50
+
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
58
+
59
+ describe 'integration' do
60
+ before :each do
61
+ class << self
62
+ alias_method :define_constant, :define_constants
63
+ end
64
+ end
65
+
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' }
79
+
80
+ it { is_expected.to define_constant(:NotAutoloaded) }
81
+
82
+ it { is_expected.to define_constant('NotAutoloaded::OldSchoolAutoload') }
83
+
84
+ it { is_expected.not_to define_constant('NotAutoloaded::Nested') }
85
+
86
+ it {
87
+ is_expected.to set_up_autoload_for_constant('NotAutoloaded::OldSchoolAutoload').
88
+ from_file('fixtures/not_autoloaded/old_school_autoload')
89
+ }
90
+
91
+ it {
92
+ is_expected.not_to set_up_autoload_for_constant('NotAutoloaded::Nested')
93
+ }
94
+ end
95
+
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
+ }
101
+
102
+ it {
103
+ is_expected.to define_constant(:AutoloadedWithConventionalFilename)
104
+ }
105
+
106
+ it {
107
+ is_expected.to define_constant('AutoloadedWithConventionalFilename::OldSchoolAutoload')
108
+ }
109
+
110
+ it {
111
+ is_expected.to define_constant('AutoloadedWithConventionalFilename::Nested')
112
+ }
113
+
114
+ it {
115
+ is_expected.not_to define_constant('AutoloadedWithConventionalFilename::NONEXISTENT')
116
+ }
117
+
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
+ }
122
+
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
170
+ end
171
+ end
172
+ end
173
+ end
@@ -0,0 +1 @@
1
+ raise "The file #{__FILE__} should not have been loaded"
@@ -0,0 +1 @@
1
+ raise "The file #{__FILE__} should not have been loaded"
@@ -0,0 +1,9 @@
1
+ module AutoloadedWithConventionalFilename
2
+
3
+ module Nested
4
+
5
+ module DoublyNested; end
6
+
7
+ end
8
+
9
+ end
@@ -0,0 +1,16 @@
1
+ require 'autoloaded'
2
+
3
+ module AutoloadedWithConventionalFilename
4
+
5
+ module Nested
6
+
7
+ # module DoublyNested; end
8
+ # autoload :DoublyNested, 'somewhere/else'
9
+
10
+ ::Autoloaded.module { }
11
+
12
+ DoublyNested
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,5 @@
1
+ module AutoloadedWithConventionalFilename
2
+
3
+ module OldSchoolAutoload; end
4
+
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'autoloaded'
2
+
3
+ module AutoloadedWithConventionalFilename
4
+
5
+ autoload :OldSchoolAutoload,
6
+ 'fixtures/autoloaded_with_conventional_filename/old_school_autoload'
7
+
8
+ ::Autoloaded.module do |autoloaded|
9
+ autoloaded.except 'N-est-ed', 'nest_ed'
10
+ end
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ module AutoloadedWithUnconventionalFilename
2
+
3
+ module Nested1; end
4
+
5
+ module Nested2; end
6
+
7
+ end
@@ -0,0 +1 @@
1
+ raise "The file #{__FILE__} should not have been loaded"
@@ -0,0 +1,5 @@
1
+ module AutoloadedWithUnconventionalFilename
2
+
3
+ module OldSchoolAutoload; end
4
+
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'autoloaded'
2
+
3
+ module AutoloadedWithUnconventionalFilename
4
+
5
+ autoload :OldSchoolAutoload,
6
+ 'fixtures/autoloaded_with_unconventional_filename/old_school_autoload'
7
+
8
+ ::Autoloaded.module do |autoloaded|
9
+ autoloaded.only 'N-est-ed' => [:Nested1, :Nested2]
10
+ end
11
+
12
+ end
File without changes