class Capybara::Widgets::PageCollection

Attributes

registry[RW]

Public Class Methods

new() click to toggle source
# File lib/capybara/widgets/core/page_collection.rb, line 13
def initialize
  self.registry = Array.new
  @loaded = false
end

Public Instance Methods

current_page_class() click to toggle source
# File lib/capybara/widgets/core/page_collection.rb, line 18
def current_page_class
  load_classes unless @loaded
  klass = registry.detect do |page_class|
    if page_class.path_matcher?
      if page_class.path_matcher.is_a?(Regexp)
        Capybara.current_path =~ page_class.path_matcher
      elsif page_class.path_matcher.is_a?(String)
        Capybara.current_path.include?(page_class.path_matcher)
      end
    else
      if page_class.path?
        Capybara.current_path.include?(page_class.path)
      else
        false
      end
    end
  end
  raise "Not found" if klass.nil?
  klass
end

Private Instance Methods

load_classes() click to toggle source
# File lib/capybara/widgets/core/page_collection.rb, line 41
def load_classes
  Dir[File.join(load_path, "**/*.rb")].each{|f| require f}
  @loaded = true
end