show_me_the_cookies 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  module ShowMeTheCookies
2
2
  require 'show_me_the_cookies/adapters/rack_test'
3
+ require 'show_me_the_cookies/adapters/poltergeist'
3
4
  require 'show_me_the_cookies/adapters/selenium'
4
5
 
5
6
  @adapters = {}
@@ -17,6 +18,7 @@ module ShowMeTheCookies
17
18
  # to register your own adapter/driver do this in your test setup code somewhere e.g. spec/support
18
19
  register_adapter(:selenium, ShowMeTheCookies::Selenium)
19
20
  register_adapter(:rack_test, ShowMeTheCookies::RackTest)
21
+ register_adapter(:poltergeist, ShowMeTheCookies::Poltergeist)
20
22
 
21
23
  # puts a string summary of the cookie
22
24
  def show_me_the_cookie(cookie_name)
@@ -0,0 +1,42 @@
1
+ class ShowMeTheCookies::Poltergeist
2
+ def initialize(driver)
3
+ @browser = driver.browser
4
+ end
5
+
6
+ def get_me_the_cookie(name)
7
+ cookie = cookies_hash[name.to_s]
8
+ translate(cookie) unless cookie.nil?
9
+ end
10
+
11
+ def get_me_the_cookies
12
+ cookies_hash.values.map(&method(:translate))
13
+ end
14
+
15
+ def expire_cookies
16
+ cookies_hash.each do |name, cookie|
17
+ delete_cookie(name) if (cookie.expires rescue nil).nil?
18
+ end
19
+ end
20
+
21
+ def delete_cookie(name)
22
+ @browser.remove_cookie(name.to_s)
23
+ end
24
+
25
+ private
26
+
27
+ def cookies_hash
28
+ @browser.cookies
29
+ end
30
+
31
+ def translate(cookie)
32
+ {
33
+ :name => cookie.name,
34
+ :domain => cookie.domain,
35
+ :value => cookie.value,
36
+ :expires => (cookie.expires rescue nil),
37
+ :path => cookie.path,
38
+ :secure => cookie.secure?,
39
+ :httponly => cookie.httponly?
40
+ }
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module ShowMeTheCookies
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency('capybara', '~> 2.0')
21
21
  s.add_development_dependency 'rspec'
22
22
  s.add_development_dependency 'sinatra'
23
+ s.add_development_dependency 'poltergeist'
23
24
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'shared_examples_for_api'
3
+ require 'capybara/poltergeist'
4
+
5
+ describe "Poltergeist", :type => :feature do
6
+ before(:each) do
7
+ Capybara.current_driver = :poltergeist
8
+ end
9
+
10
+ describe "the testing rig" do
11
+ it "should load the sinatra app" do
12
+ visit '/'
13
+ page.should have_content("Cookie setter ready")
14
+ end
15
+ end
16
+
17
+ it_behaves_like "the API"
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: show_me_the_cookies
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: poltergeist
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: Cookie manipulation for Capybara drivers -- viewing, deleting, ...
63
79
  email:
64
80
  - nick.rutherford@gmail.com
@@ -71,11 +87,13 @@ files:
71
87
  - README.md
72
88
  - Rakefile
73
89
  - lib/show_me_the_cookies.rb
90
+ - lib/show_me_the_cookies/adapters/poltergeist.rb
74
91
  - lib/show_me_the_cookies/adapters/rack_test.rb
75
92
  - lib/show_me_the_cookies/adapters/selenium.rb
76
93
  - lib/show_me_the_cookies/version.rb
77
94
  - show_me_the_cookies.gemspec
78
95
  - spec/app/set_cookie.rb
96
+ - spec/drivers/poltergeist_spec.rb
79
97
  - spec/drivers/rack-test_spec.rb
80
98
  - spec/drivers/selenium_spec.rb
81
99
  - spec/shared_examples_for_api.rb
@@ -101,12 +119,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
119
  version: '0'
102
120
  requirements: []
103
121
  rubyforge_project:
104
- rubygems_version: 1.8.23
122
+ rubygems_version: 1.8.25
105
123
  signing_key:
106
124
  specification_version: 3
107
125
  summary: Cookie manipulation for Capybara drivers
108
126
  test_files:
109
127
  - spec/app/set_cookie.rb
128
+ - spec/drivers/poltergeist_spec.rb
110
129
  - spec/drivers/rack-test_spec.rb
111
130
  - spec/drivers/selenium_spec.rb
112
131
  - spec/shared_examples_for_api.rb