autoloaded 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -8
  3. data/.rspec +1 -1
  4. data/.travis.yml +10 -0
  5. data/Gemfile +9 -10
  6. data/Guardfile +21 -22
  7. data/History.md +10 -4
  8. data/README.md +43 -30
  9. data/Rakefile +4 -0
  10. data/autoloaded.gemspec +37 -36
  11. data/bin/console +10 -0
  12. data/bin/setup +8 -0
  13. data/lib/autoloaded/autoloader.rb +6 -0
  14. data/lib/autoloaded/constant.rb +1 -0
  15. data/lib/autoloaded/deprecation.rb +0 -2
  16. data/lib/autoloaded/inflection.rb +0 -2
  17. data/lib/autoloaded/load_pathed_directory.rb +1 -3
  18. data/lib/autoloaded/specification.rb +2 -0
  19. data/lib/autoloaded/specifications.rb +0 -2
  20. data/lib/autoloaded/version.rb +1 -1
  21. data/lib/autoloaded/warning.rb +0 -2
  22. data/lib/tasks/lib_each.rake +15 -3
  23. data/lib/tasks/spec.rake +3 -6
  24. metadata +23 -110
  25. data/spec/autoloaded/autoloader_spec.rb +0 -469
  26. data/spec/autoloaded/constant_spec.rb +0 -53
  27. data/spec/autoloaded/deprecation_spec.rb +0 -23
  28. data/spec/autoloaded/inflection_spec.rb +0 -30
  29. data/spec/autoloaded/load_pathed_directory_spec.rb +0 -120
  30. data/spec/autoloaded/refine/string/to_source_filename_spec.rb +0 -19
  31. data/spec/autoloaded/specification_spec.rb +0 -98
  32. data/spec/autoloaded/specifications_spec.rb +0 -191
  33. data/spec/autoloaded/version_spec.rb +0 -3
  34. data/spec/autoloaded/warning_spec.rb +0 -115
  35. data/spec/autoloaded_macro_sharedspec.rb +0 -24
  36. data/spec/autoloaded_spec.rb +0 -321
  37. data/spec/fixtures/autoloaded_with_conventional_filename.rb +0 -12
  38. data/spec/fixtures/autoloaded_with_conventional_filename/N-est-ed.rb +0 -1
  39. data/spec/fixtures/autoloaded_with_conventional_filename/nest_ed.rb +0 -1
  40. data/spec/fixtures/autoloaded_with_conventional_filename/nested.rb +0 -16
  41. data/spec/fixtures/autoloaded_with_conventional_filename/nested/doubly_nested.rb +0 -9
  42. data/spec/fixtures/autoloaded_with_conventional_filename/old_school_autoload.rb +0 -5
  43. data/spec/fixtures/autoloaded_with_unconventional_filename.rb +0 -12
  44. data/spec/fixtures/autoloaded_with_unconventional_filename/N-est-ed.rb +0 -7
  45. data/spec/fixtures/autoloaded_with_unconventional_filename/nest_ed.rb +0 -1
  46. data/spec/fixtures/autoloaded_with_unconventional_filename/old_school_autoload.rb +0 -5
  47. data/spec/fixtures/filenames/AFilename.rb +0 -0
  48. data/spec/fixtures/filenames/a-file-name.rb +0 -0
  49. data/spec/fixtures/filenames/a-filename.rb +0 -0
  50. data/spec/fixtures/filenames/a_file_name.rb +0 -0
  51. data/spec/fixtures/filenames/a_filename.rb +0 -0
  52. data/spec/fixtures/filenames/afile-name.rb +0 -0
  53. data/spec/fixtures/filenames/afile_name.rb +0 -0
  54. data/spec/fixtures/not_autoloaded.rb +0 -5
  55. data/spec/fixtures/not_autoloaded/nested.rb +0 -1
  56. data/spec/fixtures/not_autoloaded/old_school_autoload.rb +0 -5
  57. data/spec/fixtures/old_api/autoloaded_with_conventional_filename.rb +0 -10
  58. data/spec/fixtures/old_api/autoloaded_with_conventional_filename/N-est-ed.rb +0 -1
  59. data/spec/fixtures/old_api/autoloaded_with_conventional_filename/nest_ed.rb +0 -1
  60. data/spec/fixtures/old_api/autoloaded_with_conventional_filename/nested.rb +0 -5
  61. data/spec/fixtures/old_api/autoloaded_with_conventional_filename/old_school_autoload.rb +0 -5
  62. data/spec/fixtures/old_api/autoloaded_with_conventional_filename_only.rb +0 -10
  63. data/spec/fixtures/old_api/autoloaded_with_conventional_filename_only/nested.rb +0 -5
  64. data/spec/fixtures/old_api/autoloaded_with_conventional_filename_only/old_school_autoload.rb +0 -5
  65. data/spec/fixtures/old_api/autoloaded_with_unconventional_filenames.rb +0 -10
  66. data/spec/fixtures/old_api/autoloaded_with_unconventional_filenames/N-est-ed.rb +0 -5
  67. data/spec/fixtures/old_api/autoloaded_with_unconventional_filenames/nest_ed.rb +0 -0
  68. data/spec/fixtures/old_api/autoloaded_with_unconventional_filenames/old_school_autoload.rb +0 -5
  69. data/spec/fixtures/old_api/not_autoloaded.rb +0 -6
  70. data/spec/fixtures/old_api/not_autoloaded/nested.rb +0 -1
  71. data/spec/fixtures/old_api/not_autoloaded/old_school_autoload.rb +0 -5
  72. data/spec/matchers.rb +0 -85
  73. data/spec/spec_helper.rb +0 -91
  74. data/spec/support/util.rb +0 -43
  75. data/spec/support/without_side_effects.rb +0 -37
@@ -1,7 +1,5 @@
1
1
  require 'pathname'
2
2
 
3
- module Autoloaded; end
4
-
5
3
  # Enumerates the source files in a directory, relativizing their paths using the
6
4
  # Ruby load path.
7
5
  #
@@ -97,7 +95,7 @@ private
97
95
  # Don't use Pathname#relative_path_from because we want to avoid introducing
98
96
  # double dots. The intent is to render the path as relative, if and only if
99
97
  # it is a subdirectory of 'other_path'.
100
- pattern = /^#{::Regexp.escape other_path.chomp(::File::SEPARATOR)}#{::Regexp.escape ::File::SEPARATOR}?/
98
+ pattern = /^#{::Regexp.escape other_path.to_s.chomp(::File::SEPARATOR)}#{::Regexp.escape ::File::SEPARATOR}?/
101
99
  path.gsub pattern, ''
102
100
  end
103
101
 
@@ -1,3 +1,5 @@
1
+ require 'autoloaded/inflection'
2
+
1
3
  module Autoloaded
2
4
 
3
5
  # Describes regulations for autoloading.
@@ -1,5 +1,3 @@
1
- module Autoloaded; end
2
-
3
1
  # Holds regulations for autoloading.
4
2
  #
5
3
  # @since 1.3
@@ -3,6 +3,6 @@ module Autoloaded
3
3
  # The current version of the _Autoloaded_ project.
4
4
  #
5
5
  # @since 0.0.1
6
- VERSION = '1.4.1'
6
+ VERSION = '1.5.0'
7
7
 
8
8
  end
@@ -1,5 +1,3 @@
1
- module Autoloaded; end
2
-
3
1
  # Prints warning messages to _stderr_.
4
2
  #
5
3
  # @since 1.3
@@ -1,13 +1,25 @@
1
1
  namespace :lib do
2
- desc "Load each library file individually, looking for missing 'require' statements"
2
+ desc "Check the source for missing 'require' statements. Set the 'VERBOSE' " +
3
+ 'environment variable to "t[rue]" to display the name of each file as ' +
4
+ 'it is loaded.'
3
5
  task :each do
6
+ def verbose?
7
+ ENV['VERBOSE'].to_s =~ /^T/i
8
+ end
9
+
4
10
  Dir.chdir 'lib' do
5
11
  Dir.glob( '**/*.rb' ) do |f|
6
12
  next if f == 'tasks.rb'
7
13
 
8
- puts "Loading #{f} ..."
9
- fail unless system( "/usr/bin/env bundle exec ruby -e 'require #{f.inspect}'" )
14
+ if verbose?
15
+ puts "* #{f}"
16
+ else
17
+ print "\e[32m.\e[0m"
18
+ end
19
+ command = "/usr/bin/env ruby -e 'require File.expand_path(#{f.inspect})'"
20
+ break unless system(command)
10
21
  end
11
22
  end
23
+ puts unless verbose?
12
24
  end
13
25
  end
@@ -44,7 +44,8 @@ else
44
44
  else
45
45
  noun_phrase = "#{uncommitted_spec_files.length} uncommitted spec file#{(uncommitted_spec_files.length == 1) ? nil : 's'}"
46
46
  desc = "Run #{noun_phrase}"
47
- define_spec_task :uncommitted, desc: desc, pattern: uncommitted_spec_files
47
+ define_spec_task :uncommitted, desc: desc,
48
+ pattern: uncommitted_spec_files
48
49
  end
49
50
  else
50
51
  noun_phrase = "#{uncommitted_files_in_spec.length} uncommitted file#{uncommitted_files_in_spec.length == 1 ? nil : 's'}"
@@ -52,16 +53,12 @@ else
52
53
  define_spec_task :uncommitted, desc: desc, pattern: 'spec'
53
54
  end
54
55
 
55
- define_spec_task :warnings, desc: 'Run specs with Ruby warnings enabled',
56
+ define_spec_task :warnings, desc: 'Run specs with Ruby warnings enabled',
56
57
  format: :progress,
57
58
  profile: false,
58
59
  warnings: true
59
60
  end
60
61
 
61
- desc 'Run specs'
62
- task '' => :spec
63
- task :default => :spec
64
-
65
62
  # Support the 'gem test' command.
66
63
  define_spec_task :test, desc: '', backtrace: true,
67
64
  debug: false,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoloaded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Jonsson
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-01-24 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codeclimate-test-reporter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +58,14 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '3'
61
+ version: '3.3'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '3'
68
+ version: '3.3'
55
69
  description: If you like the ‘Module#autoload’ feature of the Ruby Core library, you
56
70
  may have wished for Autoloaded. It eliminates the drudgery of handcrafting an `autoload`
57
71
  statement for each Ruby source code file in your project. It also avoids the limitations
@@ -76,6 +90,8 @@ files:
76
90
  - README.md
77
91
  - Rakefile
78
92
  - autoloaded.gemspec
93
+ - bin/console
94
+ - bin/setup
79
95
  - lib/autoloaded.rb
80
96
  - lib/autoloaded/autoloader.rb
81
97
  - lib/autoloaded/compatibility/refine_and_using.rb
@@ -95,57 +111,6 @@ files:
95
111
  - lib/tasks/lib_each.rake
96
112
  - lib/tasks/spec.rake
97
113
  - lib/tasks/spec_each.rake
98
- - spec/autoloaded/autoloader_spec.rb
99
- - spec/autoloaded/constant_spec.rb
100
- - spec/autoloaded/deprecation_spec.rb
101
- - spec/autoloaded/inflection_spec.rb
102
- - spec/autoloaded/load_pathed_directory_spec.rb
103
- - spec/autoloaded/refine/string/to_source_filename_spec.rb
104
- - spec/autoloaded/specification_spec.rb
105
- - spec/autoloaded/specifications_spec.rb
106
- - spec/autoloaded/version_spec.rb
107
- - spec/autoloaded/warning_spec.rb
108
- - spec/autoloaded_macro_sharedspec.rb
109
- - spec/autoloaded_spec.rb
110
- - spec/fixtures/autoloaded_with_conventional_filename.rb
111
- - spec/fixtures/autoloaded_with_conventional_filename/N-est-ed.rb
112
- - spec/fixtures/autoloaded_with_conventional_filename/nest_ed.rb
113
- - spec/fixtures/autoloaded_with_conventional_filename/nested.rb
114
- - spec/fixtures/autoloaded_with_conventional_filename/nested/doubly_nested.rb
115
- - spec/fixtures/autoloaded_with_conventional_filename/old_school_autoload.rb
116
- - spec/fixtures/autoloaded_with_unconventional_filename.rb
117
- - spec/fixtures/autoloaded_with_unconventional_filename/N-est-ed.rb
118
- - spec/fixtures/autoloaded_with_unconventional_filename/nest_ed.rb
119
- - spec/fixtures/autoloaded_with_unconventional_filename/old_school_autoload.rb
120
- - spec/fixtures/filenames/AFilename.rb
121
- - spec/fixtures/filenames/a-file-name.rb
122
- - spec/fixtures/filenames/a-filename.rb
123
- - spec/fixtures/filenames/a_file_name.rb
124
- - spec/fixtures/filenames/a_filename.rb
125
- - spec/fixtures/filenames/afile-name.rb
126
- - spec/fixtures/filenames/afile_name.rb
127
- - spec/fixtures/not_autoloaded.rb
128
- - spec/fixtures/not_autoloaded/nested.rb
129
- - spec/fixtures/not_autoloaded/old_school_autoload.rb
130
- - spec/fixtures/old_api/autoloaded_with_conventional_filename.rb
131
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/N-est-ed.rb
132
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/nest_ed.rb
133
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/nested.rb
134
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/old_school_autoload.rb
135
- - spec/fixtures/old_api/autoloaded_with_conventional_filename_only.rb
136
- - spec/fixtures/old_api/autoloaded_with_conventional_filename_only/nested.rb
137
- - spec/fixtures/old_api/autoloaded_with_conventional_filename_only/old_school_autoload.rb
138
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames.rb
139
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames/N-est-ed.rb
140
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames/nest_ed.rb
141
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames/old_school_autoload.rb
142
- - spec/fixtures/old_api/not_autoloaded.rb
143
- - spec/fixtures/old_api/not_autoloaded/nested.rb
144
- - spec/fixtures/old_api/not_autoloaded/old_school_autoload.rb
145
- - spec/matchers.rb
146
- - spec/spec_helper.rb
147
- - spec/support/util.rb
148
- - spec/support/without_side_effects.rb
149
114
  homepage: http://njonsson.github.io/autoloaded
150
115
  licenses:
151
116
  - MIT
@@ -166,62 +131,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
131
  version: '0'
167
132
  requirements: []
168
133
  rubyforge_project:
169
- rubygems_version: 2.2.2
134
+ rubygems_version: 2.6.8
170
135
  signing_key:
171
136
  specification_version: 4
172
137
  summary: Eliminates the drudgery of handcrafting a Ruby Core library `autoload` statement
173
138
  for each Ruby source code file in your project. It also avoids the limitations of
174
139
  rigid convention-driven facilities such as those provided by the ActiveSupport RubyGem.
175
- test_files:
176
- - spec/autoloaded/autoloader_spec.rb
177
- - spec/autoloaded/constant_spec.rb
178
- - spec/autoloaded/deprecation_spec.rb
179
- - spec/autoloaded/inflection_spec.rb
180
- - spec/autoloaded/load_pathed_directory_spec.rb
181
- - spec/autoloaded/refine/string/to_source_filename_spec.rb
182
- - spec/autoloaded/specification_spec.rb
183
- - spec/autoloaded/specifications_spec.rb
184
- - spec/autoloaded/version_spec.rb
185
- - spec/autoloaded/warning_spec.rb
186
- - spec/autoloaded_macro_sharedspec.rb
187
- - spec/autoloaded_spec.rb
188
- - spec/fixtures/autoloaded_with_conventional_filename.rb
189
- - spec/fixtures/autoloaded_with_conventional_filename/N-est-ed.rb
190
- - spec/fixtures/autoloaded_with_conventional_filename/nest_ed.rb
191
- - spec/fixtures/autoloaded_with_conventional_filename/nested.rb
192
- - spec/fixtures/autoloaded_with_conventional_filename/nested/doubly_nested.rb
193
- - spec/fixtures/autoloaded_with_conventional_filename/old_school_autoload.rb
194
- - spec/fixtures/autoloaded_with_unconventional_filename.rb
195
- - spec/fixtures/autoloaded_with_unconventional_filename/N-est-ed.rb
196
- - spec/fixtures/autoloaded_with_unconventional_filename/nest_ed.rb
197
- - spec/fixtures/autoloaded_with_unconventional_filename/old_school_autoload.rb
198
- - spec/fixtures/filenames/AFilename.rb
199
- - spec/fixtures/filenames/a-file-name.rb
200
- - spec/fixtures/filenames/a-filename.rb
201
- - spec/fixtures/filenames/a_file_name.rb
202
- - spec/fixtures/filenames/a_filename.rb
203
- - spec/fixtures/filenames/afile-name.rb
204
- - spec/fixtures/filenames/afile_name.rb
205
- - spec/fixtures/not_autoloaded.rb
206
- - spec/fixtures/not_autoloaded/nested.rb
207
- - spec/fixtures/not_autoloaded/old_school_autoload.rb
208
- - spec/fixtures/old_api/autoloaded_with_conventional_filename.rb
209
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/N-est-ed.rb
210
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/nest_ed.rb
211
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/nested.rb
212
- - spec/fixtures/old_api/autoloaded_with_conventional_filename/old_school_autoload.rb
213
- - spec/fixtures/old_api/autoloaded_with_conventional_filename_only.rb
214
- - spec/fixtures/old_api/autoloaded_with_conventional_filename_only/nested.rb
215
- - spec/fixtures/old_api/autoloaded_with_conventional_filename_only/old_school_autoload.rb
216
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames.rb
217
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames/N-est-ed.rb
218
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames/nest_ed.rb
219
- - spec/fixtures/old_api/autoloaded_with_unconventional_filenames/old_school_autoload.rb
220
- - spec/fixtures/old_api/not_autoloaded.rb
221
- - spec/fixtures/old_api/not_autoloaded/nested.rb
222
- - spec/fixtures/old_api/not_autoloaded/old_school_autoload.rb
223
- - spec/matchers.rb
224
- - spec/spec_helper.rb
225
- - spec/support/util.rb
226
- - spec/support/without_side_effects.rb
227
- has_rdoc:
140
+ test_files: []
@@ -1,469 +0,0 @@
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