module Workarea::TestCase::Decoration

Public Class Methods

load_decorator(path) click to toggle source
# File lib/workarea/test_case.rb, line 7
def self.load_decorator(path)
  unless loaded_decorators.include?(path) || !File.file?(path)
    load path
    loaded_decorators << path
  end
end

Public Instance Methods

inherited(subclass) click to toggle source
Calls superclass method
# File lib/workarea/test_case.rb, line 14
def inherited(subclass)
  super

  absolute_path = caller[0].split(':').first
  # Don't try to find decorators for classes in the testing gem
  return if absolute_path.include?('workarea-testing') ||
              absolute_path.include?('workarea/testing')

  relative_path = absolute_path.match(/(\/test.*)/).to_s
  decorator_relative = relative_path.gsub(
    '.rb',
    ".#{Rails::Decorators.extension}"
  )

  (Plugin.installed.map(&:root) + [Rails.root]).each do |root|
    decorator_location = [root, decorator_relative].join

    if File.exist?(decorator_location)
      TestCase::Decoration.load_decorator(decorator_location)
    end
  end
end