show_me_the_cookies 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "cucumber", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.2"
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Nicholas Rutherford
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = show_me_the_cookies
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to show_me_the_cookies
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Nicholas Rutherford. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "show_me_the_cookies"
16
+ gem.homepage = "http://github.com/nruth/show_me_the_cookies"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Cookie manipulation for Capybara drivers}
19
+ gem.description = %Q{Cookie manipulation for Capybara drivers -- viewing, deleting, ...}
20
+ gem.email = "nick.rutherford@gmail.com"
21
+ gem.authors = ["Nicholas Rutherford"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'cucumber/rake/task'
30
+ Cucumber::Rake::Task.new(:features)
31
+
32
+ task :default => :spec
33
+
34
+ require 'rake/rdoctask'
35
+ Rake::RDocTask.new do |rdoc|
36
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
37
+
38
+ rdoc.rdoc_dir = 'rdoc'
39
+ rdoc.title = "show_me_the_cookies #{version}"
40
+ rdoc.rdoc_files.include('README*')
41
+ rdoc.rdoc_files.include('lib/**/*.rb')
42
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.2
@@ -0,0 +1,9 @@
1
+ Feature: something something
2
+ In order to something something
3
+ A user something something
4
+ something something something
5
+
6
+ Scenario: something something
7
+ Given inspiration
8
+ When I create a sweet new gem
9
+ Then everyone should see how awesome I am
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
11
+ require 'show_me_the_cookies'
12
+
13
+ require 'rspec/expectations'
@@ -0,0 +1,52 @@
1
+ module ShowMeTheCookies
2
+
3
+ require 'show_me_the_cookies/culerity'
4
+ require 'show_me_the_cookies/rack_test'
5
+ require 'show_me_the_cookies/selenium'
6
+
7
+ def current_driver_adapter
8
+ case (current_driver = Capybara.current_session.driver)
9
+ when Capybara::Driver::Selenium
10
+ ShowMeTheCookies::Selenium.new(current_driver.browser)
11
+ when Capybara::Driver::RackTest
12
+ ShowMeTheCookies::RackTest.new(current_driver)
13
+ when Capybara::Driver::Culerity
14
+ ShowMeTheCookies::Culerity.new(current_driver.browser)
15
+ else
16
+ unsupported_driver_spam
17
+ end
18
+ end
19
+
20
+ def self.session_cookie_name=(name)
21
+ @@session_cookie_name = name
22
+ end
23
+
24
+ def show_me_the_cookies
25
+ announce "Current cookies: #{current_driver_adapter.show_me_the_cookies}"
26
+ end
27
+
28
+ def delete_cookie(cookie_name)
29
+ announce current_driver_adapter.show_me_the_cookies if @announce
30
+ current_driver_adapter.delete_cookie(cookie_name)
31
+ announce "Deleted cookie: #{cookie_name}" if @announce
32
+ announce current_driver_adapter.show_me_the_cookies if @announce
33
+ end
34
+
35
+ private
36
+ @@session_cookie_name = nil
37
+
38
+ def self.unsupported_browser_spam
39
+ raise "unsupported driver, use rack::test, selenium/webdriver or culerity"
40
+ end
41
+
42
+ # Rails.application.config.session_options[:key] #for rails 3, courtesy of https://github.com/ilpoldo
43
+ #else just hard code it as follows
44
+ #'_appname_session' #or check in browser for what your app is using
45
+ def session_cookie_name
46
+ begin
47
+ @@session_cookie_name || Rails.application.config.session_options[:key]
48
+ rescue NoMethodError => e
49
+ raise "set ShowMeTheCookies.session_cookie_name= for your rails 2 app"
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ class ShowMeTheCookies::Culerity
2
+ def initialize(browser)
3
+ @browser = browser
4
+ end
5
+
6
+ def show_me_the_cookies
7
+ @browser.cookies.send_remote(:inspect)
8
+ end
9
+
10
+ def delete_cookie(cookie_name)
11
+ @browser.remove_cookie('localhost', cookie_name)
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ class ShowMeTheCookies::RackTest
2
+ def initialize(rack_test_driver)
3
+ @rack_test_driver = rack_test_driver
4
+ end
5
+
6
+ def show_me_the_cookies
7
+ cookie_jar.instance_variable_get(:@cookies).map(&:inspect).join("\n")
8
+ end
9
+
10
+ def delete_cookie(cookie_name)
11
+ cookie_jar.instance_variable_get(:@cookies).reject! do |existing_cookie|
12
+ existing_cookie.name.downcase == cookie_name
13
+ end
14
+ end
15
+
16
+ private
17
+ def cookie_jar
18
+ @rack_test_driver.current_session.instance_variable_get(:@rack_mock_session).cookie_jar
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ class ShowMeTheCookies::Selenium
2
+ def initialize(browser)
3
+ @browser = browser
4
+ self
5
+ end
6
+
7
+ def show_me_the_cookies
8
+ @browser.manage.all_cookies.map(&:inspect).join("\n")
9
+ end
10
+
11
+ def delete_cookie(cookie_name)
12
+ @browser.manage.delete_cookie(cookie_name)
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: show_me_the_cookies
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - Nicholas Rutherford
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-07 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ name: cucumber
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ prerelease: false
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ name: bundler
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 23
44
+ segments:
45
+ - 1
46
+ - 0
47
+ - 0
48
+ version: 1.0.0
49
+ prerelease: false
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ name: jeweler
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 1
62
+ - 5
63
+ - 2
64
+ version: 1.5.2
65
+ prerelease: false
66
+ requirement: *id003
67
+ description: Cookie manipulation for Capybara drivers -- viewing, deleting, ...
68
+ email: nick.rutherford@gmail.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - LICENSE.txt
75
+ - README.rdoc
76
+ files:
77
+ - .document
78
+ - .rspec
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.rdoc
82
+ - Rakefile
83
+ - VERSION
84
+ - features/show_me_the_cookies.feature
85
+ - features/step_definitions/show_me_the_cookies_steps.rb
86
+ - features/support/env.rb
87
+ - lib/show_me_the_cookies.rb
88
+ - lib/show_me_the_cookies/culerity.rb
89
+ - lib/show_me_the_cookies/rack_test.rb
90
+ - lib/show_me_the_cookies/selenium.rb
91
+ has_rdoc: true
92
+ homepage: http://github.com/nruth/show_me_the_cookies
93
+ licenses:
94
+ - MIT
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.4.2
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Cookie manipulation for Capybara drivers
125
+ test_files: []
126
+