Class: Capybara::Widgets::PageCollection

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/capybara/widgets/core/page_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePageCollection

Returns a new instance of PageCollection.



13
14
15
16
# File 'lib/capybara/widgets/core/page_collection.rb', line 13

def initialize
  self.registry = Array.new
  @loaded = false
end

Instance Attribute Details

#registryObject

Returns the value of attribute registry.



9
10
11
# File 'lib/capybara/widgets/core/page_collection.rb', line 9

def registry
  @registry
end

Instance Method Details

#current_page_classObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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