show_me_the_cookies 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ module ShowMeTheCookies
2
2
  require 'show_me_the_cookies/rack_test'
3
3
  require 'show_me_the_cookies/selenium'
4
4
  require 'show_me_the_cookies/akephalos'
5
+ require 'show_me_the_cookies/poltergeist'
5
6
 
6
7
  # puts a string summary of the cookie
7
8
  def show_me_the_cookie(cookie_name)
@@ -38,9 +39,10 @@ module ShowMeTheCookies
38
39
  private
39
40
  def adapters
40
41
  @@drivers ||= {
41
- :selenium => ShowMeTheCookies::Selenium,
42
- :rack_test => ShowMeTheCookies::RackTest,
43
- :akephalos => ShowMeTheCookies::Akephalos
42
+ :selenium => ShowMeTheCookies::Selenium,
43
+ :rack_test => ShowMeTheCookies::RackTest,
44
+ :akephalos => ShowMeTheCookies::Akephalos,
45
+ :poltergeist => ShowMeTheCookies::Poltergeist
44
46
  }
45
47
  end
46
48
 
@@ -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 = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency 'rspec'
22
22
  s.add_development_dependency 'sinatra'
23
23
  s.add_development_dependency 'akephalos2'
24
+ s.add_development_dependency 'poltergeist'
24
25
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'shared_examples_for_api'
3
+ require 'capybara/poltergeist'
4
+
5
+ describe "Poltergeist", :type => :request 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,95 +1,110 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: show_me_the_cookies
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.4
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 3
10
- version: 1.1.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Nicholas Rutherford
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-08-19 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capybara
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
18
+ requirements:
25
19
  - - ~>
26
- - !ruby/object:Gem::Version
27
- hash: 15
28
- segments:
29
- - 1
30
- - 0
31
- version: "1.0"
32
- requirement: *id001
33
- name: capybara
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
34
22
  type: :runtime
35
- - !ruby/object:Gem::Dependency
36
23
  prerelease: false
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
38
25
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
46
- requirement: *id002
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
47
31
  name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
48
38
  type: :development
49
- - !ruby/object:Gem::Dependency
50
39
  prerelease: false
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
52
41
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
60
- requirement: *id003
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
61
47
  name: sinatra
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
62
54
  type: :development
63
- - !ruby/object:Gem::Dependency
64
55
  prerelease: false
65
- version_requirements: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
66
57
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
72
- - 0
73
- version: "0"
74
- requirement: *id004
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
75
63
  name: akephalos2
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
76
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'
78
+ - !ruby/object:Gem::Dependency
79
+ name: poltergeist
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
77
94
  description: Cookie manipulation for Capybara drivers -- viewing, deleting, ...
78
- email:
95
+ email:
79
96
  - nick.rutherford@gmail.com
80
97
  executables: []
81
-
82
98
  extensions: []
83
-
84
99
  extra_rdoc_files: []
85
-
86
- files:
100
+ files:
87
101
  - .gitignore
88
102
  - Gemfile
89
103
  - README.md
90
104
  - Rakefile
91
105
  - lib/show_me_the_cookies.rb
92
106
  - lib/show_me_the_cookies/akephalos.rb
107
+ - lib/show_me_the_cookies/poltergeist.rb
93
108
  - lib/show_me_the_cookies/rack_test.rb
94
109
  - lib/show_me_the_cookies/selenium.rb
95
110
  - lib/show_me_the_cookies/version.rb
@@ -97,47 +112,47 @@ files:
97
112
  - spec/app/set_cookie.rb
98
113
  - spec/request/akephalos_spec.rb
99
114
  - spec/request/custom_spec.rb
115
+ - spec/request/poltergeist_spec.rb
100
116
  - spec/request/rack-test_spec.rb
101
117
  - spec/request/selenium_spec.rb
102
118
  - spec/shared_examples_for_api.rb
103
119
  - spec/spec_helper.rb
104
120
  homepage: https://github.com/nruth/show_me_the_cookies
105
- licenses:
121
+ licenses:
106
122
  - MIT
107
123
  post_install_message:
108
124
  rdoc_options: []
109
-
110
- require_paths:
125
+ require_paths:
111
126
  - lib
112
- required_ruby_version: !ruby/object:Gem::Requirement
127
+ required_ruby_version: !ruby/object:Gem::Requirement
113
128
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
119
134
  - 0
120
- version: "0"
121
- required_rubygems_version: !ruby/object:Gem::Requirement
135
+ hash: 2634854024742574363
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
137
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ segments:
128
143
  - 0
129
- version: "0"
144
+ hash: 2634854024742574363
130
145
  requirements: []
131
-
132
146
  rubyforge_project:
133
- rubygems_version: 1.8.15
147
+ rubygems_version: 1.8.23
134
148
  signing_key:
135
149
  specification_version: 3
136
150
  summary: Cookie manipulation for Capybara drivers
137
- test_files:
151
+ test_files:
138
152
  - spec/app/set_cookie.rb
139
153
  - spec/request/akephalos_spec.rb
140
154
  - spec/request/custom_spec.rb
155
+ - spec/request/poltergeist_spec.rb
141
156
  - spec/request/rack-test_spec.rb
142
157
  - spec/request/selenium_spec.rb
143
158
  - spec/shared_examples_for_api.rb