gauss:rubyspec brian$ ../mspec/bin/mspec -tr19 -fs core/module/autoload_spec.rb
ruby 1.9.2dev (2009-02-04 trunk 22023) [i386-darwin9.6.0]
Module#autoload?
- returns the name of the file that will be autoloaded
- returns nil if no file has been registered for a constant
Module#autoload
- registers a file to load the first time the named constant is accessed
- sets the autoload constant in the constants table
- loads the registered constant when it is accessed
- loads the registered constant into a dynamically created class
- loads the registered constant into a dynamically created module
- loads the registered constant when it is opened as a class
- loads the registered constant when it is opened as a module
- loads the registered constant when it is inherited from
- loads the registered constand when it is included
- does not load the file when the constant is already set
- loads a file with .rb extension when passed the name without the extension
- does not load the file if the file is manually required
- allows multiple autoload constants for a single file
- does not call Kernel#require or Kernel#load dynamically
- removes the constant from the constant table if load fails (FAILED - 1)
- removes the constant from the constant table if the loaded files does not define it (FAILED - 2)
- does not load the file when accessing the constants table of the module
- does not load the file when removing an autoload constant (ERROR - 3)
- does not load the file when refering to the constant in defined? (ERROR - 4)
- loads the file when opening a module that is the autoloaded constant
- raises a NameError when the autoload file did not define the constant and a module is opened with the same name
- raises an ArgumentError when an empty filename is given
- raises a NameError when the constant name starts with a lower case letter
- raises a NameError when the constant name starts with a number
- raises a NameError when the constant name has a space in it
- shares the autoload request across dup'ed copies of modules
1)
Module#autoload removes the constant from the constant table if load fails FAILED
Expected ModuleSpecs::Autoload NOT to have constant 'Fail' but it does
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:134:in `block (2 levels) in <top (required)>'
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:15:in `<top (required)>'
2)
Module#autoload removes the constant from the constant table if the loaded files does not define it FAILED
Expected ModuleSpecs::Autoload NOT to have constant 'O' but it does
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:142:in `block (2 levels) in <top (required)>'
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:15:in `<top (required)>'
3)
Module#autoload does not load the file when removing an autoload constant ERROR
LoadError: no such file to load -- autoload.rb
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:153:in `<module:Q>'
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:151:in `block (2 levels) in <top (required)>'
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:15:in `<top (required)>'
4)
Module#autoload does not load the file when refering to the constant in defined? ERROR
LoadError: no such file to load -- autoload.rb
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:162:in `<module:Q>'
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:160:in `block (2 levels) in <top (required)>'
/Users/brian/devel/rubyspec/core/module/autoload_spec.rb:15:in `<top (required)>'
Finished in 0.010806 seconds
1 file, 28 examples, 45 expectations, 2 failures, 2 errors