Module: RSpecMagic::Unstable::IncludeDirContext::Exports

Defined in:
lib/rspec_magic/unstable/include_dir_context.rb

Instance Method Summary collapse

Instance Method Details

#include_dir_context(dir) ⇒ void

Include the relevant shared contexts hierarchy.

Parameters:

  • dir (String)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rspec_magic/unstable/include_dir_context.rb', line 19

def include_dir_context(dir)
  root = Config.spec_path

  d, steps = dir, []
  while d.start_with?(root)
    steps << d
    d = File.split(d).first
  end

  steps.reverse.each do |d|
    begin; include_context d; rescue ArgumentError; end
  end
end