rails-session_cookie 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aaebe5fd70ce3e0e10e605f5293af233d5fedd98
4
+ data.tar.gz: 1a5245e091c0dae70ce4941ba61f32da06e046ac
5
+ SHA512:
6
+ metadata.gz: ccaee593138ee4dc61a25a1952017a98516ebdff2814a4200a63a0cd6503bea61b802c7a34e53e76a08a780d4305f078f9d49af53d7fa36c8e1a03db81bcd598
7
+ data.tar.gz: f081b17921a95d6aa87ae4e9ec20ca5cf3d9efb11f11a74a5803da3981d94fbf5391704f572d6a5457c6beef977a6e617a9a725ed70634cb726139d3ebd48666
@@ -0,0 +1,3 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: false
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'gemfiles/vendor/**/*'
4
+ Metrics/LineLength:
5
+ Max: 120
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - 'spec/**/*_spec.rb'
@@ -0,0 +1,15 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 2.4.1
6
+ - 2.3.4
7
+ - 2.2.7
8
+ gemfile:
9
+ - gemfiles/rails_4.2.gemfile
10
+ - gemfiles/rails_5.0.gemfile
11
+ - gemfiles/rails_5.1.gemfile
12
+ before_install: gem install bundler -v 1.15.4
13
+ script:
14
+ - bundle exec rake
15
+ - bundle exec codeclimate-test-reporter
@@ -0,0 +1,11 @@
1
+ appraise 'rails-4.2' do
2
+ gem 'rails', '~> 4.2.9'
3
+ end
4
+
5
+ appraise 'rails-5.0' do
6
+ gem 'rails', '~> 5.0.5'
7
+ end
8
+
9
+ appraise 'rails-5.1' do
10
+ gem 'rails', '~> 5.1.3'
11
+ end
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem 'pry-byebug' unless ENV['CI']
6
+
7
+ # Specify your gem's dependencies in rails-session_cookie.gemspec
8
+ gemspec
@@ -0,0 +1,115 @@
1
+ # Rails::SessionCookie
2
+
3
+ Fast, loosely coupled requests specs for a cookie-authenticated application.
4
+
5
+ [![Gem Version][GV img]][Gem Version]
6
+ [![Build Status][BS img]][Build Status]
7
+ [![Code Climate][CC img]][Code Climate]
8
+ [![Coverage][CV img]][Coverage]
9
+
10
+ ## Why
11
+
12
+ Probably, you might have seen a lot code like this:
13
+
14
+ ```ruby
15
+ # config/initializers/session_store.rb
16
+ Rails.application.config.session_store :cookie_store
17
+
18
+ # authentificaing method (maybe Devise or whatever)
19
+ session[:current_user_id] = current_user.id
20
+
21
+ # somewhere in helper for request specs
22
+ def login(current_user)
23
+ post '/login', auth_data(current_user)
24
+ end
25
+
26
+ # now every request spec is calling login request
27
+ RSpec.describe 'User inferface', type: :request do
28
+ let(:user) { create :user }
29
+
30
+ before do
31
+ login(user)
32
+ end
33
+
34
+ it 'shows private data' do
35
+ get '/dashboard'
36
+ end
37
+ end
38
+ ```
39
+
40
+ In a usual user-driven application this tightly couples *all* request specs, which require authentication, to the login process.
41
+ If it fails - everything fails. If it's not blazingly fast - it slows the whole suite down.
42
+
43
+ One may move to token-based authentification, especially when having API. That's reasonable and nice.
44
+ But we can think about a session cookie as a token passed in a special header!
45
+
46
+ This gem replaces your usual process with the simplest 2 rails middleware pass.
47
+ Rails is modular, that's cool :)
48
+
49
+ ## Installation
50
+
51
+ ```ruby
52
+ # Gemfile
53
+ gem 'rails-session_cookie', group: :test
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ ```ruby
59
+ # spec_helper.rb
60
+ require 'rails/session_cookie'
61
+
62
+ def login(current_user)
63
+ # depending on Rails version and session configuration this looks like "cookie_store_key=data--digest; path=/; HttpOnly"
64
+ raw_session_cookie = Rails::SessionCookie::App.new(current_user_id: current_user.id).session_cookie
65
+
66
+ # note, it's raw, not `<<`
67
+ cookies.merge(raw_session_cookie)
68
+ end
69
+
70
+ # ...everything else the same
71
+ ```
72
+
73
+ Now you can cache `raw_session_cookie` globally or per-thread depending on `current_user_id` to get things even faster!
74
+
75
+ You can also use the `raw_session_cookie` directly like this:
76
+
77
+ ```
78
+ get "/", {}, { "HTTP_COOKIE" => raw_session_cookie }
79
+ ```
80
+
81
+ Strictly speaking, you may cache `Set-Cookie` response header from `/login` URL to achieve same speed (but not coupling ;)
82
+ However, never saw this in practice, and consider caching of requests in before-phase bad. YMMV.
83
+
84
+ ## Advanced usage
85
+
86
+ If you need more sophisticated logic:
87
+
88
+ ```ruby
89
+ auth_app = proc { |env|
90
+ # do your magic
91
+ env[Rails::SessionCookie::RACK_SESSION].merge!(context)
92
+ [200, {}, []]
93
+ }
94
+ raw_session_cookie = Rails::SessionCookie::App.new(auth_app).session_cookie
95
+ end
96
+ ```
97
+
98
+ Of course, you can just make use (and reuse!) of as many procs as you wish.
99
+
100
+ This effectively achieves the effect as [this PR#18230](https://github.com/rails/rails/pull/18230/files), which allows session mutation
101
+ in a less invasive way in regard to Rails itself ;)
102
+
103
+ ## Contributing
104
+
105
+ Bug reports and pull requests are welcome on GitHub at https://github.com/razum2um/rails-session_cookie.
106
+
107
+ [Gem Version]: https://rubygems.org/gems/rails-session_cookie
108
+ [Build Status]: https://travis-ci.org/razum2um/rails-session_cookie
109
+ [Code Climate]: https://codeclimate.com/github/razum2um/rails-session_cookie
110
+ [Coverage]: https://codeclimate.com/github/razum2um/rails-session_cookie/coverage
111
+
112
+ [GV img]: https://badge.fury.io/rb/rails-session_cookie.png
113
+ [BS img]: https://travis-ci.org/razum2um/rails-session_cookie.png
114
+ [CC img]: https://codeclimate.com/github/razum2um/rails-session_cookie/badges/gpa.svg
115
+ [CV img]: https://codeclimate.com/github/razum2um/rails-session_cookie/badges/coverage.svg
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
7
+
8
+ task default: %i[rubocop spec]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'rails/session_cookie'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry-byebug"
6
+ gem "rails", "~> 4.2.9"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,181 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails-session_cookie (0.1.0)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.9)
11
+ actionpack (= 4.2.9)
12
+ actionview (= 4.2.9)
13
+ activejob (= 4.2.9)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.9)
17
+ actionview (= 4.2.9)
18
+ activesupport (= 4.2.9)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.9)
24
+ activesupport (= 4.2.9)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
29
+ activejob (4.2.9)
30
+ activesupport (= 4.2.9)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.9)
33
+ activesupport (= 4.2.9)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.9)
36
+ activemodel (= 4.2.9)
37
+ activesupport (= 4.2.9)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.9)
40
+ i18n (~> 0.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ appraisal (2.2.0)
45
+ bundler
46
+ rake
47
+ thor (>= 0.14.0)
48
+ arel (6.0.4)
49
+ ast (2.3.0)
50
+ builder (3.2.3)
51
+ byebug (9.0.6)
52
+ codeclimate-test-reporter (1.0.8)
53
+ simplecov (<= 0.13)
54
+ coderay (1.1.1)
55
+ concurrent-ruby (1.0.5)
56
+ diff-lcs (1.3)
57
+ docile (1.1.5)
58
+ erubis (2.7.0)
59
+ globalid (0.4.0)
60
+ activesupport (>= 4.2.0)
61
+ i18n (0.8.6)
62
+ json (2.1.0)
63
+ loofah (2.0.3)
64
+ nokogiri (>= 1.5.9)
65
+ mail (2.6.6)
66
+ mime-types (>= 1.16, < 4)
67
+ method_source (0.8.2)
68
+ mime-types (3.1)
69
+ mime-types-data (~> 3.2015)
70
+ mime-types-data (3.2016.0521)
71
+ mini_portile2 (2.2.0)
72
+ minitest (5.10.3)
73
+ nokogiri (1.8.0)
74
+ mini_portile2 (~> 2.2.0)
75
+ parallel (1.12.0)
76
+ parser (2.4.0.0)
77
+ ast (~> 2.2)
78
+ powerpack (0.1.1)
79
+ pry (0.10.4)
80
+ coderay (~> 1.1.0)
81
+ method_source (~> 0.8.1)
82
+ slop (~> 3.4)
83
+ pry-byebug (3.4.2)
84
+ byebug (~> 9.0)
85
+ pry (~> 0.10)
86
+ rack (1.6.8)
87
+ rack-test (0.6.3)
88
+ rack (>= 1.0)
89
+ rails (4.2.9)
90
+ actionmailer (= 4.2.9)
91
+ actionpack (= 4.2.9)
92
+ actionview (= 4.2.9)
93
+ activejob (= 4.2.9)
94
+ activemodel (= 4.2.9)
95
+ activerecord (= 4.2.9)
96
+ activesupport (= 4.2.9)
97
+ bundler (>= 1.3.0, < 2.0)
98
+ railties (= 4.2.9)
99
+ sprockets-rails
100
+ rails-deprecated_sanitizer (1.0.3)
101
+ activesupport (>= 4.2.0.alpha)
102
+ rails-dom-testing (1.0.8)
103
+ activesupport (>= 4.2.0.beta, < 5.0)
104
+ nokogiri (~> 1.6)
105
+ rails-deprecated_sanitizer (>= 1.0.1)
106
+ rails-html-sanitizer (1.0.3)
107
+ loofah (~> 2.0)
108
+ railties (4.2.9)
109
+ actionpack (= 4.2.9)
110
+ activesupport (= 4.2.9)
111
+ rake (>= 0.8.7)
112
+ thor (>= 0.18.1, < 2.0)
113
+ rainbow (2.2.2)
114
+ rake
115
+ rake (10.5.0)
116
+ rspec (3.6.0)
117
+ rspec-core (~> 3.6.0)
118
+ rspec-expectations (~> 3.6.0)
119
+ rspec-mocks (~> 3.6.0)
120
+ rspec-core (3.6.0)
121
+ rspec-support (~> 3.6.0)
122
+ rspec-expectations (3.6.0)
123
+ diff-lcs (>= 1.2.0, < 2.0)
124
+ rspec-support (~> 3.6.0)
125
+ rspec-mocks (3.6.0)
126
+ diff-lcs (>= 1.2.0, < 2.0)
127
+ rspec-support (~> 3.6.0)
128
+ rspec-rails (3.6.1)
129
+ actionpack (>= 3.0)
130
+ activesupport (>= 3.0)
131
+ railties (>= 3.0)
132
+ rspec-core (~> 3.6.0)
133
+ rspec-expectations (~> 3.6.0)
134
+ rspec-mocks (~> 3.6.0)
135
+ rspec-support (~> 3.6.0)
136
+ rspec-support (3.6.0)
137
+ rubocop (0.49.1)
138
+ parallel (~> 1.10)
139
+ parser (>= 2.3.3.1, < 3.0)
140
+ powerpack (~> 0.1)
141
+ rainbow (>= 1.99.1, < 3.0)
142
+ ruby-progressbar (~> 1.7)
143
+ unicode-display_width (~> 1.0, >= 1.0.1)
144
+ ruby-progressbar (1.8.1)
145
+ simplecov (0.13.0)
146
+ docile (~> 1.1.0)
147
+ json (>= 1.8, < 3)
148
+ simplecov-html (~> 0.10.0)
149
+ simplecov-html (0.10.2)
150
+ slop (3.6.0)
151
+ sprockets (3.7.1)
152
+ concurrent-ruby (~> 1.0)
153
+ rack (> 1, < 3)
154
+ sprockets-rails (3.2.1)
155
+ actionpack (>= 4.0)
156
+ activesupport (>= 4.0)
157
+ sprockets (>= 3.0.0)
158
+ thor (0.20.0)
159
+ thread_safe (0.3.6)
160
+ tzinfo (1.2.3)
161
+ thread_safe (~> 0.1)
162
+ unicode-display_width (1.3.0)
163
+
164
+ PLATFORMS
165
+ ruby
166
+
167
+ DEPENDENCIES
168
+ appraisal (~> 2.2)
169
+ bundler (~> 1.15)
170
+ codeclimate-test-reporter (= 1.0.8)
171
+ pry-byebug
172
+ rails (~> 4.2.9)
173
+ rails-session_cookie!
174
+ rake (~> 10.0)
175
+ rspec (~> 3.0)
176
+ rspec-rails (~> 3.6.1)
177
+ rubocop (~> 0.49)
178
+ simplecov (= 0.13.0)
179
+
180
+ BUNDLED WITH
181
+ 1.15.4
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry-byebug"
6
+ gem "rails", "~> 5.0.5"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,187 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails-session_cookie (0.1.0)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.0.5)
11
+ actionpack (= 5.0.5)
12
+ nio4r (>= 1.2, < 3.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.0.5)
15
+ actionpack (= 5.0.5)
16
+ actionview (= 5.0.5)
17
+ activejob (= 5.0.5)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.0.5)
21
+ actionview (= 5.0.5)
22
+ activesupport (= 5.0.5)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.0.5)
28
+ activesupport (= 5.0.5)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.0.5)
34
+ activesupport (= 5.0.5)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.0.5)
37
+ activesupport (= 5.0.5)
38
+ activerecord (5.0.5)
39
+ activemodel (= 5.0.5)
40
+ activesupport (= 5.0.5)
41
+ arel (~> 7.0)
42
+ activesupport (5.0.5)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ appraisal (2.2.0)
48
+ bundler
49
+ rake
50
+ thor (>= 0.14.0)
51
+ arel (7.1.4)
52
+ ast (2.3.0)
53
+ builder (3.2.3)
54
+ byebug (9.0.6)
55
+ codeclimate-test-reporter (1.0.8)
56
+ simplecov (<= 0.13)
57
+ coderay (1.1.1)
58
+ concurrent-ruby (1.0.5)
59
+ diff-lcs (1.3)
60
+ docile (1.1.5)
61
+ erubis (2.7.0)
62
+ globalid (0.4.0)
63
+ activesupport (>= 4.2.0)
64
+ i18n (0.8.6)
65
+ json (2.1.0)
66
+ loofah (2.0.3)
67
+ nokogiri (>= 1.5.9)
68
+ mail (2.6.6)
69
+ mime-types (>= 1.16, < 4)
70
+ method_source (0.8.2)
71
+ mime-types (3.1)
72
+ mime-types-data (~> 3.2015)
73
+ mime-types-data (3.2016.0521)
74
+ mini_portile2 (2.2.0)
75
+ minitest (5.10.3)
76
+ nio4r (2.1.0)
77
+ nokogiri (1.8.0)
78
+ mini_portile2 (~> 2.2.0)
79
+ parallel (1.12.0)
80
+ parser (2.4.0.0)
81
+ ast (~> 2.2)
82
+ powerpack (0.1.1)
83
+ pry (0.10.4)
84
+ coderay (~> 1.1.0)
85
+ method_source (~> 0.8.1)
86
+ slop (~> 3.4)
87
+ pry-byebug (3.4.2)
88
+ byebug (~> 9.0)
89
+ pry (~> 0.10)
90
+ rack (2.0.3)
91
+ rack-test (0.6.3)
92
+ rack (>= 1.0)
93
+ rails (5.0.5)
94
+ actioncable (= 5.0.5)
95
+ actionmailer (= 5.0.5)
96
+ actionpack (= 5.0.5)
97
+ actionview (= 5.0.5)
98
+ activejob (= 5.0.5)
99
+ activemodel (= 5.0.5)
100
+ activerecord (= 5.0.5)
101
+ activesupport (= 5.0.5)
102
+ bundler (>= 1.3.0)
103
+ railties (= 5.0.5)
104
+ sprockets-rails (>= 2.0.0)
105
+ rails-dom-testing (2.0.3)
106
+ activesupport (>= 4.2.0)
107
+ nokogiri (>= 1.6)
108
+ rails-html-sanitizer (1.0.3)
109
+ loofah (~> 2.0)
110
+ railties (5.0.5)
111
+ actionpack (= 5.0.5)
112
+ activesupport (= 5.0.5)
113
+ method_source
114
+ rake (>= 0.8.7)
115
+ thor (>= 0.18.1, < 2.0)
116
+ rainbow (2.2.2)
117
+ rake
118
+ rake (10.5.0)
119
+ rspec (3.6.0)
120
+ rspec-core (~> 3.6.0)
121
+ rspec-expectations (~> 3.6.0)
122
+ rspec-mocks (~> 3.6.0)
123
+ rspec-core (3.6.0)
124
+ rspec-support (~> 3.6.0)
125
+ rspec-expectations (3.6.0)
126
+ diff-lcs (>= 1.2.0, < 2.0)
127
+ rspec-support (~> 3.6.0)
128
+ rspec-mocks (3.6.0)
129
+ diff-lcs (>= 1.2.0, < 2.0)
130
+ rspec-support (~> 3.6.0)
131
+ rspec-rails (3.6.1)
132
+ actionpack (>= 3.0)
133
+ activesupport (>= 3.0)
134
+ railties (>= 3.0)
135
+ rspec-core (~> 3.6.0)
136
+ rspec-expectations (~> 3.6.0)
137
+ rspec-mocks (~> 3.6.0)
138
+ rspec-support (~> 3.6.0)
139
+ rspec-support (3.6.0)
140
+ rubocop (0.49.1)
141
+ parallel (~> 1.10)
142
+ parser (>= 2.3.3.1, < 3.0)
143
+ powerpack (~> 0.1)
144
+ rainbow (>= 1.99.1, < 3.0)
145
+ ruby-progressbar (~> 1.7)
146
+ unicode-display_width (~> 1.0, >= 1.0.1)
147
+ ruby-progressbar (1.8.1)
148
+ simplecov (0.13.0)
149
+ docile (~> 1.1.0)
150
+ json (>= 1.8, < 3)
151
+ simplecov-html (~> 0.10.0)
152
+ simplecov-html (0.10.2)
153
+ slop (3.6.0)
154
+ sprockets (3.7.1)
155
+ concurrent-ruby (~> 1.0)
156
+ rack (> 1, < 3)
157
+ sprockets-rails (3.2.1)
158
+ actionpack (>= 4.0)
159
+ activesupport (>= 4.0)
160
+ sprockets (>= 3.0.0)
161
+ thor (0.20.0)
162
+ thread_safe (0.3.6)
163
+ tzinfo (1.2.3)
164
+ thread_safe (~> 0.1)
165
+ unicode-display_width (1.3.0)
166
+ websocket-driver (0.6.5)
167
+ websocket-extensions (>= 0.1.0)
168
+ websocket-extensions (0.1.2)
169
+
170
+ PLATFORMS
171
+ ruby
172
+
173
+ DEPENDENCIES
174
+ appraisal (~> 2.2)
175
+ bundler (~> 1.15)
176
+ codeclimate-test-reporter (= 1.0.8)
177
+ pry-byebug
178
+ rails (~> 5.0.5)
179
+ rails-session_cookie!
180
+ rake (~> 10.0)
181
+ rspec (~> 3.0)
182
+ rspec-rails (~> 3.6.1)
183
+ rubocop (~> 0.49)
184
+ simplecov (= 0.13.0)
185
+
186
+ BUNDLED WITH
187
+ 1.15.4
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pry-byebug"
6
+ gem "rails", "~> 5.1.3"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,187 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rails-session_cookie (0.1.0)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.1.3)
11
+ actionpack (= 5.1.3)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.1.3)
15
+ actionpack (= 5.1.3)
16
+ actionview (= 5.1.3)
17
+ activejob (= 5.1.3)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.1.3)
21
+ actionview (= 5.1.3)
22
+ activesupport (= 5.1.3)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.1.3)
28
+ activesupport (= 5.1.3)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.1.3)
34
+ activesupport (= 5.1.3)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.1.3)
37
+ activesupport (= 5.1.3)
38
+ activerecord (5.1.3)
39
+ activemodel (= 5.1.3)
40
+ activesupport (= 5.1.3)
41
+ arel (~> 8.0)
42
+ activesupport (5.1.3)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ appraisal (2.2.0)
48
+ bundler
49
+ rake
50
+ thor (>= 0.14.0)
51
+ arel (8.0.0)
52
+ ast (2.3.0)
53
+ builder (3.2.3)
54
+ byebug (9.0.6)
55
+ codeclimate-test-reporter (1.0.8)
56
+ simplecov (<= 0.13)
57
+ coderay (1.1.1)
58
+ concurrent-ruby (1.0.5)
59
+ diff-lcs (1.3)
60
+ docile (1.1.5)
61
+ erubi (1.6.1)
62
+ globalid (0.4.0)
63
+ activesupport (>= 4.2.0)
64
+ i18n (0.8.6)
65
+ json (2.1.0)
66
+ loofah (2.0.3)
67
+ nokogiri (>= 1.5.9)
68
+ mail (2.6.6)
69
+ mime-types (>= 1.16, < 4)
70
+ method_source (0.8.2)
71
+ mime-types (3.1)
72
+ mime-types-data (~> 3.2015)
73
+ mime-types-data (3.2016.0521)
74
+ mini_portile2 (2.2.0)
75
+ minitest (5.10.3)
76
+ nio4r (2.1.0)
77
+ nokogiri (1.8.0)
78
+ mini_portile2 (~> 2.2.0)
79
+ parallel (1.12.0)
80
+ parser (2.4.0.0)
81
+ ast (~> 2.2)
82
+ powerpack (0.1.1)
83
+ pry (0.10.4)
84
+ coderay (~> 1.1.0)
85
+ method_source (~> 0.8.1)
86
+ slop (~> 3.4)
87
+ pry-byebug (3.4.2)
88
+ byebug (~> 9.0)
89
+ pry (~> 0.10)
90
+ rack (2.0.3)
91
+ rack-test (0.6.3)
92
+ rack (>= 1.0)
93
+ rails (5.1.3)
94
+ actioncable (= 5.1.3)
95
+ actionmailer (= 5.1.3)
96
+ actionpack (= 5.1.3)
97
+ actionview (= 5.1.3)
98
+ activejob (= 5.1.3)
99
+ activemodel (= 5.1.3)
100
+ activerecord (= 5.1.3)
101
+ activesupport (= 5.1.3)
102
+ bundler (>= 1.3.0)
103
+ railties (= 5.1.3)
104
+ sprockets-rails (>= 2.0.0)
105
+ rails-dom-testing (2.0.3)
106
+ activesupport (>= 4.2.0)
107
+ nokogiri (>= 1.6)
108
+ rails-html-sanitizer (1.0.3)
109
+ loofah (~> 2.0)
110
+ railties (5.1.3)
111
+ actionpack (= 5.1.3)
112
+ activesupport (= 5.1.3)
113
+ method_source
114
+ rake (>= 0.8.7)
115
+ thor (>= 0.18.1, < 2.0)
116
+ rainbow (2.2.2)
117
+ rake
118
+ rake (10.5.0)
119
+ rspec (3.6.0)
120
+ rspec-core (~> 3.6.0)
121
+ rspec-expectations (~> 3.6.0)
122
+ rspec-mocks (~> 3.6.0)
123
+ rspec-core (3.6.0)
124
+ rspec-support (~> 3.6.0)
125
+ rspec-expectations (3.6.0)
126
+ diff-lcs (>= 1.2.0, < 2.0)
127
+ rspec-support (~> 3.6.0)
128
+ rspec-mocks (3.6.0)
129
+ diff-lcs (>= 1.2.0, < 2.0)
130
+ rspec-support (~> 3.6.0)
131
+ rspec-rails (3.6.1)
132
+ actionpack (>= 3.0)
133
+ activesupport (>= 3.0)
134
+ railties (>= 3.0)
135
+ rspec-core (~> 3.6.0)
136
+ rspec-expectations (~> 3.6.0)
137
+ rspec-mocks (~> 3.6.0)
138
+ rspec-support (~> 3.6.0)
139
+ rspec-support (3.6.0)
140
+ rubocop (0.49.1)
141
+ parallel (~> 1.10)
142
+ parser (>= 2.3.3.1, < 3.0)
143
+ powerpack (~> 0.1)
144
+ rainbow (>= 1.99.1, < 3.0)
145
+ ruby-progressbar (~> 1.7)
146
+ unicode-display_width (~> 1.0, >= 1.0.1)
147
+ ruby-progressbar (1.8.1)
148
+ simplecov (0.13.0)
149
+ docile (~> 1.1.0)
150
+ json (>= 1.8, < 3)
151
+ simplecov-html (~> 0.10.0)
152
+ simplecov-html (0.10.2)
153
+ slop (3.6.0)
154
+ sprockets (3.7.1)
155
+ concurrent-ruby (~> 1.0)
156
+ rack (> 1, < 3)
157
+ sprockets-rails (3.2.1)
158
+ actionpack (>= 4.0)
159
+ activesupport (>= 4.0)
160
+ sprockets (>= 3.0.0)
161
+ thor (0.20.0)
162
+ thread_safe (0.3.6)
163
+ tzinfo (1.2.3)
164
+ thread_safe (~> 0.1)
165
+ unicode-display_width (1.3.0)
166
+ websocket-driver (0.6.5)
167
+ websocket-extensions (>= 0.1.0)
168
+ websocket-extensions (0.1.2)
169
+
170
+ PLATFORMS
171
+ ruby
172
+
173
+ DEPENDENCIES
174
+ appraisal (~> 2.2)
175
+ bundler (~> 1.15)
176
+ codeclimate-test-reporter (= 1.0.8)
177
+ pry-byebug
178
+ rails (~> 5.1.3)
179
+ rails-session_cookie!
180
+ rake (~> 10.0)
181
+ rspec (~> 3.0)
182
+ rspec-rails (~> 3.6.1)
183
+ rubocop (~> 0.49)
184
+ simplecov (= 0.13.0)
185
+
186
+ BUNDLED WITH
187
+ 1.15.4
@@ -0,0 +1,8 @@
1
+ require 'rails/session_cookie/app'
2
+ require 'rails/session_cookie/version'
3
+
4
+ module Rails
5
+ # :nodoc:
6
+ module SessionCookie
7
+ end
8
+ end
@@ -0,0 +1,57 @@
1
+ require 'rack'
2
+ require 'active_support'
3
+ require 'action_dispatch'
4
+
5
+ module Rails
6
+ module SessionCookie
7
+ NoRailsApplication = Class.new(StandardError)
8
+ RACK_SESSION = 'rack.session'.freeze # upstream constant name is changing
9
+
10
+ # This mini rack app allows easily get rails session cookie
11
+ class App
12
+ def self.simple_app_from_session_hash(session = {})
13
+ proc { |env|
14
+ session.each do |k, v|
15
+ env[RACK_SESSION][k] = v
16
+ end
17
+ [200, {}, []]
18
+ }
19
+ end
20
+
21
+ attr_reader :app, :rails_app
22
+
23
+ def initialize(app, session_options = nil)
24
+ auth_session_options = session_options || rails_app.config.session_options
25
+ auth_app = app.respond_to?(:call) ? app : self.class.simple_app_from_session_hash(app)
26
+ @app = with_session_cookie_middlewares(auth_app, auth_session_options)
27
+ end
28
+
29
+ def call(env = {})
30
+ app.call(default_env.merge(env).dup)
31
+ end
32
+
33
+ def session_cookie(env = {})
34
+ _status, headers, _body = call(env)
35
+ headers[ActionDispatch::Cookies::HTTP_HEADER]
36
+ end
37
+
38
+ private
39
+
40
+ def with_session_cookie_middlewares(app, session_options)
41
+ ActionDispatch::Cookies.new(
42
+ ActionDispatch::Session::CookieStore.new(
43
+ app, session_options
44
+ )
45
+ )
46
+ end
47
+
48
+ def default_env
49
+ rails_app.env_config.merge('REQUEST_METHOD' => 'GET')
50
+ end
51
+
52
+ def rails_app
53
+ @rails_app ||= defined?(Rails) && Rails.application || raise(NoRailsApplication)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ module Rails
2
+ module SessionCookie
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'rails/session_cookie/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'rails-session_cookie'
9
+ spec.version = Rails::SessionCookie::VERSION
10
+ spec.authors = ['Vlad Bokov']
11
+ spec.email = ['razum2um@mail.ru']
12
+
13
+ spec.summary = 'Mini rack-app to get raw rails session cookie'
14
+ spec.description = 'Helps to get proper integration tests run faster'
15
+ spec.homepage = 'https://github.com/razum2um/rails/session_cookie'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'rails', '>= 4.0'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.15'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'appraisal', '~> 2.2'
30
+ spec.add_development_dependency 'rubocop', '~> 0.49'
31
+ spec.add_development_dependency 'rspec-rails', '~> 3.6.1'
32
+ spec.add_development_dependency 'codeclimate-test-reporter', '= 1.0.8'
33
+ spec.add_development_dependency 'simplecov', '= 0.13.0'
34
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-session_cookie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vlad Bokov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: appraisal
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.49'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.49'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.6.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.6.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: codeclimate-test-reporter
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.0.8
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.0.8
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.13.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.13.0
139
+ description: Helps to get proper integration tests run faster
140
+ email:
141
+ - razum2um@mail.ru
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".codeclimate.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - ".travis.yml"
151
+ - Appraisals
152
+ - Gemfile
153
+ - README.md
154
+ - Rakefile
155
+ - bin/console
156
+ - bin/setup
157
+ - gemfiles/.bundle/config
158
+ - gemfiles/rails_4.2.gemfile
159
+ - gemfiles/rails_4.2.gemfile.lock
160
+ - gemfiles/rails_5.0.gemfile
161
+ - gemfiles/rails_5.0.gemfile.lock
162
+ - gemfiles/rails_5.1.gemfile
163
+ - gemfiles/rails_5.1.gemfile.lock
164
+ - lib/rails/session_cookie.rb
165
+ - lib/rails/session_cookie/app.rb
166
+ - lib/rails/session_cookie/version.rb
167
+ - rails-session_cookie.gemspec
168
+ homepage: https://github.com/razum2um/rails/session_cookie
169
+ licenses: []
170
+ metadata: {}
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubyforge_project:
187
+ rubygems_version: 2.6.11
188
+ signing_key:
189
+ specification_version: 4
190
+ summary: Mini rack-app to get raw rails session cookie
191
+ test_files: []