Class: Symbiont::Page

Inherits:
Object show all
Extended by:
Element
Includes:
Capybara::DSL, Ready
Defined in:
lib/symbiont/capybara/page.rb

Class Attribute Summary collapse

Attributes included from Ready

#ready, #ready_error

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Element

element, elements, region, regions

Methods included from Ready

included, #ready?, #ready_validations_pass?, #when_ready

Constructor Details

#initialize(&block) ⇒ Page

Returns a new instance of Page.



29
30
31
32
# File 'lib/symbiont/capybara/page.rb', line 29

def initialize(&block)
  super
  instance_eval(&block) if block
end

Class Attribute Details

.urlObject (readonly)

Returns the value of attribute url.



14
15
16
# File 'lib/symbiont/capybara/page.rb', line 14

def url
  @url
end

Class Method Details

.url_is(url) ⇒ Object



16
17
18
# File 'lib/symbiont/capybara/page.rb', line 16

def url_is(url)
  @url = url.to_s
end

.url_matcherObject



24
25
26
# File 'lib/symbiont/capybara/page.rb', line 24

def url_matcher
  @url_matcher || url
end

.url_matches(url) ⇒ Object



20
21
22
# File 'lib/symbiont/capybara/page.rb', line 20

def url_matches(url)
  @url_matcher = url
end

Instance Method Details

#displayed?Boolean

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/symbiont/capybara/page.rb', line 69

def displayed?
  fail Symbiont::Errors::NoUrlMatchForDefinition if url_matcher.nil?
  true
end

#perform(*args) ⇒ Object



56
57
58
59
# File 'lib/symbiont/capybara/page.rb', line 56

def perform(*args)
  view(*args)
  self
end

#secure?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/symbiont/capybara/page.rb', line 74

def secure?
  !current_url.match(/^https/).nil?
end

#urlObject



61
62
63
# File 'lib/symbiont/capybara/page.rb', line 61

def url
  self.class.url
end

#url_matcherObject



65
66
67
# File 'lib/symbiont/capybara/page.rb', line 65

def url_matcher
  self.class.url_matcher
end

#view(content = {}, &block) ⇒ Object Also known as: load



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/symbiont/capybara/page.rb', line 38

def view(content = {}, &block)
  self.ready = false

  if content.is_a?(String)
    @page = Capybara.string(content)
  else
    location = url
    fail Symbiont::Errors::NoUrlForDefinition if location.nil?
    visit url
  end

  when_ready(&block) if block_given?
end