Class: Capybara::Driver::Celerity

Inherits:
Base
  • Object
show all
Defined in:
lib/capybara/driver/celerity.rb

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Celerity

Returns a new instance of Celerity.



99
100
101
102
103
104
# File 'lib/capybara/driver/celerity.rb', line 99

def initialize(app, options={})
  @app = app
  @options = options
  @rack_server = Capybara::Server.new(@app)
  @rack_server.boot if Capybara.run_server
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



97
98
99
# File 'lib/capybara/driver/celerity.rb', line 97

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



97
98
99
# File 'lib/capybara/driver/celerity.rb', line 97

def options
  @options
end

#rack_serverObject (readonly)

Returns the value of attribute rack_server.



97
98
99
# File 'lib/capybara/driver/celerity.rb', line 97

def rack_server
  @rack_server
end

Instance Method Details

#bodyObject



118
119
120
# File 'lib/capybara/driver/celerity.rb', line 118

def body
  browser.document.as_xml
end

#browserObject



145
146
147
148
149
150
151
152
# File 'lib/capybara/driver/celerity.rb', line 145

def browser
  unless @_browser
    require 'celerity'
    @_browser = ::Celerity::Browser.new(options)
  end

  @_browser
end

#current_urlObject



110
111
112
# File 'lib/capybara/driver/celerity.rb', line 110

def current_url
  browser.url
end

#evaluate_script(script) ⇒ Object



141
142
143
# File 'lib/capybara/driver/celerity.rb', line 141

def evaluate_script(script)
  browser.execute_script "#{script}"
end

#execute_script(script) ⇒ Object



136
137
138
139
# File 'lib/capybara/driver/celerity.rb', line 136

def execute_script(script)
  browser.execute_script script
  nil
end

#find(selector) ⇒ Object



130
131
132
# File 'lib/capybara/driver/celerity.rb', line 130

def find(selector)
  browser.elements_by_xpath(selector).map { |node| Node.new(self, node) }
end

#reset!Object



154
155
156
# File 'lib/capybara/driver/celerity.rb', line 154

def reset!
  browser.clear_cookies
end

#response_headersObject



122
123
124
# File 'lib/capybara/driver/celerity.rb', line 122

def response_headers
  browser.response_headers
end

#sourceObject



114
115
116
# File 'lib/capybara/driver/celerity.rb', line 114

def source
  browser.html
end

#status_codeObject



126
127
128
# File 'lib/capybara/driver/celerity.rb', line 126

def status_code
  browser.status_code
end

#visit(path) ⇒ Object



106
107
108
# File 'lib/capybara/driver/celerity.rb', line 106

def visit(path)
  browser.goto(url(path))
end

#wait?Boolean

Returns:

  • (Boolean)


134
# File 'lib/capybara/driver/celerity.rb', line 134

def wait?; true; end