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
I highly recomment NOT using this method.
Instance Method Details
#add_cookie(attribs) ⇒ Object
77 78 79 |
# File 'lib/monkey-patches/capybara-patches.rb', line 77 def (attribs) driver.(attribs) end |
#cookie_named(name) ⇒ Hash?
Get the cookie with the given name
65 66 67 |
# File 'lib/monkey-patches/capybara-patches.rb', line 65 def (name) driver.(name) end |
#cookies ⇒ Array<Hash>
Get all cookies
55 56 57 |
# File 'lib/monkey-patches/capybara-patches.rb', line 55 def driver. end |
#delete_all_cookies ⇒ Object
73 74 75 |
# File 'lib/monkey-patches/capybara-patches.rb', line 73 def driver. end |
#delete_cookie(cookie) ⇒ Object
69 70 71 |
# File 'lib/monkey-patches/capybara-patches.rb', line 69 def () driver.() end |
#validate(source) ⇒ Object
I highly recomment NOT using this method
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/monkey-patches/capybara-patches.rb', line 86 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 if(RUBY_PLATFORM == 'java') #this works source = source.gsub(/PUBLIC \"-\/\/W3C\/\/DTD XHTML.*?\/\/EN\" \"http:\/\/www.w3.org.*?\"/, "SYSTEM \"#{dtd}\"") doc = Nokogiri::XML(source) { |cfg| cfg.noent.dtdload.dtdvalid } doc = Nokogiri::XML(source) errors = doc.validate else #this doesn't - nokogiri issues require 'open-uri' doc = Nokogiri::XML(open(driver.current_url, :proxy => ENV['PROXY_URL'])) do |config| config.strict.noent end #xsd = Nokogiri::XML::Schema(File.read("#{File.dirname( __FILE__)}/../../schemas/xhtml1-strict.xsd")) xsd = Nokogiri::XML::Schema(open('http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd', :proxy => ENV['PROXY_URL'])) errors = xsd.validate(doc) end raise "Page (#{current_url}) failed XHTML vaidation (or Nokogiri Freaked out...please manually check against W3C), errors:#{errors.to_s}" unless errors == [] end |