Sha256: e0e27c2ba3f4a952437b20d851c6e2fc720535e11eb5865e38d062d9f6f32e56

Contents?: true

Size: 1.89 KB

Versions: 63

Compression:

Stored size: 1.89 KB

Contents

module Shoulda # :nodoc:
  # Call autoload_macros when you want to load test macros automatically in a non-Rails 
  # project (it's done automatically for Rails projects).
  # You don't need to specify ROOT/test/shoulda_macros explicitly. Your custom macros
  # are loaded automatically when you call autoload_macros.
  #
  # The first argument is the path to you application's root directory.
  # All following arguments are directories relative to your root, which contain 
  # shoulda_macros subdirectories. These directories support the same kinds of globs as the 
  # Dir class.
  # 
  # Basic usage (from a test_helper):
  # Shoulda.autoload_macros(File.dirname(__FILE__) + '/..')
  #	will load everything in 
  #	- your_app/test/shoulda_macros
  #
  #	To load vendored macros as well:
  # Shoulda.autoload_macros(APP_ROOT, 'vendor/*')
  #	will load everything in 
  #	- APP_ROOT/vendor/*/shoulda_macros
  #	- APP_ROOT/test/shoulda_macros
  #
  #	To load macros in an app with a vendor directory laid out like Rails':
  # Shoulda.autoload_macros(APP_ROOT, 'vendor/{plugins,gems}/*')
  # or
  # Shoulda.autoload_macros(APP_ROOT, 'vendor/plugins/*', 'vendor/gems/*')
  #	will load everything in 
  #	- APP_ROOT/vendor/plugins/*/shoulda_macros
  #	- APP_ROOT/vendor/gems/*/shoulda_macros
  #	- APP_ROOT/test/shoulda_macros
  #
  #	If you prefer to stick testing dependencies away from your production dependencies:
  # Shoulda.autoload_macros(APP_ROOT, 'vendor/*', 'test/vendor/*')
  #	will load everything in 
  #	- APP_ROOT/vendor/*/shoulda_macros
  #	- APP_ROOT/test/vendor/*/shoulda_macros
  #	- APP_ROOT/test/shoulda_macros
  def self.autoload_macros(root, *dirs)
    dirs << File.join('test')
    complete_dirs = dirs.map{|d| File.join(root, d, 'shoulda_macros')}
    all_files     = complete_dirs.inject([]){ |files, dir| files + Dir[File.join(dir, '*.rb')] }
    all_files.each do |file|
      require file
    end
  end
end

Version data entries

63 entries across 63 versions & 17 rubygems

Version Path
simply_stated-0.0.5 vendor/gems/ruby/1.8/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb
simply_stated-0.0.4 vendor/gems/ruby/1.8/gems/shoulda-2.10.3/lib/shoulda/autoload_macros.rb
shoulda-2.10.3 lib/shoulda/autoload_macros.rb
shoulda-2.9.0 lib/shoulda/autoload_macros.rb
shoulda-2.9.1 lib/shoulda/autoload_macros.rb
shoulda-2.9.2 lib/shoulda/autoload_macros.rb
shoulda-2.10.0 lib/shoulda/autoload_macros.rb
shoulda-2.10.1 lib/shoulda/autoload_macros.rb
tpitale-shoulda-2.11.0 lib/shoulda/autoload_macros.rb
shoulda-2.10.2 lib/shoulda/autoload_macros.rb
poolparty-1.3.15 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.14 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.13 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.8 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.7 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.6 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.4 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.3 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
poolparty-1.3.1 vendor/gems/shoulda/lib/shoulda/autoload_macros.rb
gnip-1.0.0 test/lib/shoulda/autoload_macros.rb