Browse files

Capybara 2.0 update. Removes all extra drivers.

Only rack-test and selenium support for now. #12
  • Loading branch information...
1 parent 3541149 commit ee1380bf0e77b3143639a36b8142e6b869529863 @nruth committed Jan 5, 2013
View
2 README.md
@@ -54,7 +54,7 @@ Add to your gemfile's test group:
in step_helper or your support directory:
RSpec.configure do |config|
- config.include ShowMeTheCookies, :type => :request
+ config.include ShowMeTheCookies, :type => :feature
end
### Example usage
View
6 lib/show_me_the_cookies.rb
@@ -1,8 +1,6 @@
module ShowMeTheCookies
require 'show_me_the_cookies/rack_test'
require 'show_me_the_cookies/selenium'
- require 'show_me_the_cookies/akephalos'
- require 'show_me_the_cookies/poltergeist'
# puts a string summary of the cookie
def show_me_the_cookie(cookie_name)
@@ -40,9 +38,7 @@ def expire_cookies
def adapters
@@drivers ||= {
:selenium => ShowMeTheCookies::Selenium,
- :rack_test => ShowMeTheCookies::RackTest,
- :akephalos => ShowMeTheCookies::Akephalos,
- :poltergeist => ShowMeTheCookies::Poltergeist
+ :rack_test => ShowMeTheCookies::RackTest
}
end
View
61 lib/show_me_the_cookies/akephalos.rb
@@ -1,61 +0,0 @@
-class ShowMeTheCookies::Akephalos
- def initialize(driver)
- @driver = driver
- @browser = driver.browser
- end
-
- def get_me_the_cookie(cookie_name)
- cookie = get_me_the_raw_cookie(cookie_name)
- cookie && _translate_cookie(cookie)
- end
-
- def get_me_the_cookies
- cookies.map {|c| _translate_cookie(c) }
- end
-
- def delete_cookie(cookie_name)
- cookie = get_me_the_raw_cookie(cookie_name)
- @browser.cookies.delete(cookie) if cookie
- end
-
- def expire_cookies
- cookies.each do |c|
- # it drops expired cookies for us, so just remove session cookies
- # we don't care that it's a badly decoded java date object, just that it's present
- delete_cookie(c.name) if c.expires == nil
- end
- end
-
-private
- def get_me_the_raw_cookie(cookie_name)
- @browser.cookies[cookie_name.to_s]
- end
-
- def cookies
- @browser.cookies.to_a
- end
-
- def _translate_cookie(cookie)
- c = {:name => cookie.name.to_s,
- :domain => cookie.domain,
- :value => cookie.value,
- :expires => cookie.expires,
- :path => cookie.path
- }
- # Akephalos2 returns a java.util.Date or somesuch that looks like this, so we
- # remove it if necessary
- #
- # {:value=>"249920784.1048820629.1318215489.1318215489.1318215489.1",
- # :path=>"/",
- # :domain=>"gw.lvh.me",
- # :name=>"__utma",
- # :expires=>
- # #<DRb::DRbUnknown:0x11d7825d0
- # @buf=
- # "\004\bU:\031Java::JavaUtil::Date\"3\254?sr\000\016java.util.Datehj\201\001KYt\031\003\000\000xpw\b\000\000\001A\233&\250\200x",
- # @name="Java::">},
- #
- c[:expires] = nil if c[:expires].class.name == "DRb::DRbUnknown"
- c
- end
-end
View
42 lib/show_me_the_cookies/poltergeist.rb
@@ -1,42 +0,0 @@
-class ShowMeTheCookies::Poltergeist
- def initialize(driver)
- @browser = driver.browser
- end
-
- def get_me_the_cookie(name)
- cookie = cookies_hash[name.to_s]
- translate(cookie) unless cookie.nil?
- end
-
- def get_me_the_cookies
- cookies_hash.values.map(&method(:translate))
- end
-
- def expire_cookies
- cookies_hash.each do |name, cookie|
- delete_cookie(name) if (cookie.expires rescue nil).nil?
- end
- end
-
- def delete_cookie(name)
- @browser.remove_cookie(name.to_s)
- end
-
- private
-
- def cookies_hash
- @browser.cookies
- end
-
- def translate(cookie)
- {
- :name => cookie.name,
- :domain => cookie.domain,
- :value => cookie.value,
- :expires => (cookie.expires rescue nil),
- :path => cookie.path,
- :secure => cookie.secure?,
- :httponly => cookie.httponly?
- }
- end
-end
View
4 show_me_the_cookies.gemspec
@@ -17,9 +17,7 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency('capybara', '~> 1.0')
+ s.add_dependency('capybara', '~> 2.0')
s.add_development_dependency 'rspec'
s.add_development_dependency 'sinatra'
- s.add_development_dependency 'akephalos2'
- s.add_development_dependency 'poltergeist'
end
View
2 spec/request/rack-test_spec.rb → spec/drivers/rack-test_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'shared_examples_for_api'
-describe "RackTest", :type => :request do
+describe "RackTest", :type => :feature do
before(:each) do
Capybara.current_driver = :rack_test
end
View
2 spec/request/selenium_spec.rb → spec/drivers/selenium_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'shared_examples_for_api'
-describe "Selenium Webdriver", :type => :request do
+describe "Selenium Webdriver", :type => :feature do
before(:each) do
Capybara.current_driver = :selenium
end
View
18 spec/request/akephalos_spec.rb
@@ -1,18 +0,0 @@
-require 'spec_helper'
-require 'shared_examples_for_api'
-require 'akephalos'
-
-describe "Akephalos (HTMLUnit)", :type => :request do
- before(:each) do
- Capybara.current_driver = :akephalos
- end
-
- describe "the testing rig" do
- it "should load the sinatra app" do
- visit '/'
- page.should have_content("Cookie setter ready")
- end
- end
-
- it_behaves_like "the API"
-end
View
22 spec/request/custom_spec.rb
@@ -1,22 +0,0 @@
-require 'spec_helper'
-require 'shared_examples_for_api'
-
-describe "Custom Webdriver", :type => :request do
- before(:all) do
- Capybara.register_driver :custom do |app|
- Capybara::Selenium::Driver.new(app, :resynchronize => true)
- end
- end
- before(:each) do
- Capybara.current_driver = :custom
- end
-
- describe "the testing rig" do
- it "should load the sinatra app" do
- visit '/'
- page.should have_content("Cookie setter ready")
- end
- end
-
- it_behaves_like "the API"
-end
View
18 spec/request/poltergeist_spec.rb
@@ -1,18 +0,0 @@
-require 'spec_helper'
-require 'shared_examples_for_api'
-require 'capybara/poltergeist'
-
-describe "Poltergeist", :type => :request do
- before(:each) do
- Capybara.current_driver = :poltergeist
- end
-
- describe "the testing rig" do
- it "should load the sinatra app" do
- visit '/'
- page.should have_content("Cookie setter ready")
- end
- end
-
- it_behaves_like "the API"
-end
View
2 spec/spec_helper.rb
@@ -5,5 +5,5 @@
require 'show_me_the_cookies'
RSpec.configure do |config|
- config.include ShowMeTheCookies, :type => :request
+ config.include ShowMeTheCookies, :type => :feature
end

0 comments on commit ee1380b

Please sign in to comment.