Class: Capybara::Session
- Inherits:
-
Object
- Object
- Capybara::Session
- Defined in:
- lib/monkey-patches/capybara-patches.rb
Constant Summary collapse
- DTD_REFS =
{ "-//W3C//DTD XHTML 1.0 Strict//EN" => {:dtd => "#{File.dirname( __FILE__)}/../../schemas/xhtml1-strict.dtd", :type => :strict}, "-//W3C//DTD XHTML 1.0 Transitional//EN" => {:dtd => "#{File.dirname( __FILE__)}/../../schemas/xhtml1-transitional.dtd", :type => :transitional}, "-//W3C//DTD XHTML+RDFa 1.0//EN" => {:dtd => "#{File.dirname( __FILE__)}/../../schemas/xhtml-rdfa-1.dtd", :type => :rdfa}}
Instance Method Summary collapse
- #add_cookie(attribs) ⇒ Object
-
#cookie_named(name) ⇒ Hash?
Get the cookie with the given name.
-
#cookies ⇒ Array<Hash>
Get all cookies.
- #delete_all_cookies ⇒ Object
- #delete_cookie(cookie) ⇒ Object
- #validate(source) ⇒ Object
Instance Method Details
#add_cookie(attribs) ⇒ Object
76 77 78 |
# File 'lib/monkey-patches/capybara-patches.rb', line 76 def (attribs) driver.(attribs) end |
#cookie_named(name) ⇒ Hash?
Get the cookie with the given name
64 65 66 |
# File 'lib/monkey-patches/capybara-patches.rb', line 64 def (name) driver.(name) end |
#cookies ⇒ Array<Hash>
Get all cookies
54 55 56 |
# File 'lib/monkey-patches/capybara-patches.rb', line 54 def driver. end |
#delete_all_cookies ⇒ Object
72 73 74 |
# File 'lib/monkey-patches/capybara-patches.rb', line 72 def driver. end |
#delete_cookie(cookie) ⇒ Object
68 69 70 |
# File 'lib/monkey-patches/capybara-patches.rb', line 68 def () driver.() end |
#validate(source) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/monkey-patches/capybara-patches.rb', line 85 def validate(source) doctype = source.scan(/\"(.*?)\"/)[0].to_s if(DTD_REFS[doctype]) dtd = DTD_REFS[doctype][:dtd] type = DTD_REFS[doctype][:type] end raise "RDFA Validation not currently supported due to issues in Nokogiri" if type == :rdfa source = source.gsub(/PUBLIC \"-\/\/W3C\/\/DTD XHTML.*?\/\/EN\" \"http:\/\/www.w3.org.*?\"/, "SYSTEM \"#{dtd}\"") doc = Nokogiri::XML(source) { |cfg| cfg.noent.dtdload.dtdvalid } errors = doc.validate raise "Page (#{current_url}) failed XHTML vaidation (or Nokogiri Freaked out...please manually check against W3C), errors:#{errors.to_s}" unless errors == [] end |