Class: Webrat::CuleritySession

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
SaveAndOpenPage
Defined in:
lib/webrat/culerity/session.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SaveAndOpenPage

#doc_root, #open_in_browser, #rewrite_css_and_image_references, #save_and_open_page, #saved_page_dir

Constructor Details

#initialize(*args) ⇒ CuleritySession

:nodoc:



20
21
# File 'lib/webrat/culerity/session.rb', line 20

def initialize(*args) # :nodoc:
end

Instance Attribute Details

#current_urlObject (readonly)

Returns the value of attribute current_url.



18
19
20
# File 'lib/webrat/culerity/session.rb', line 18

def current_url
  @current_url
end

Instance Method Details

#base_scopeObject



66
67
68
# File 'lib/webrat/culerity/session.rb', line 66

def base_scope
  @_base_scope ||= CulerityScope.new(container)
end

#clear_cookiesObject



50
51
52
# File 'lib/webrat/culerity/session.rb', line 50

def clear_cookies
  container.clear_cookies
end


35
36
37
38
39
# File 'lib/webrat/culerity/session.rb', line 35

def click_link_within(selector, text_or_title_or_id)
  within(selector) do
    click_link(text_or_title_or_id)
  end
end

#current_scopeObject



58
59
60
# File 'lib/webrat/culerity/session.rb', line 58

def current_scope
  scopes.last || base_scope
end

#execute_script(source) ⇒ Object



54
55
56
# File 'lib/webrat/culerity/session.rb', line 54

def execute_script(source)
  container.execute_script(source)
end

#reloadObject



43
44
45
46
# File 'lib/webrat/culerity/session.rb', line 43

def reload
  reset
  container.refresh
end

#responseObject



23
24
25
# File 'lib/webrat/culerity/session.rb', line 23

def response
  CulerityResponse.new(response_body)
end

#scopesObject



62
63
64
# File 'lib/webrat/culerity/session.rb', line 62

def scopes
  @_scopes ||= []
end

#visit(url = nil, http_method = :get, data = {}) ⇒ Object



27
28
29
30
31
# File 'lib/webrat/culerity/session.rb', line 27

def visit(url = nil, http_method = :get, data = {})
  reset
  # TODO querify data
  @current_url = container.goto(absolute_url(url))
end

#within(selector) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/webrat/culerity/session.rb', line 70

def within(selector)
  xpath = Webrat::XML.css_to_xpath(selector).first
  scope = CulerityScope.new(container.element_by_xpath(xpath))
  scopes.push(scope)
  ret = yield
  scopes.pop
  return ret
end

#within_frame(name) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/webrat/culerity/session.rb', line 79

def within_frame(name)
  scope = CulerityScope.new(container.frame(:name => name))
  scopes.push(scope)
  if block_given?
    ret = yield
    scopes.pop
    return ret
  end
  scope
end