devise_specs 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81d919f6bedb5fd92fa4c892518b62f68fc888cce3a85c8f668870507bee10c9
4
- data.tar.gz: dcf1599ab23ca4ba5774701c0561bde7465f0d5b9f9d52603c85bf404290cb4c
3
+ metadata.gz: 6a1cff4227df932e424d78abf6edb5b7ea7c1967ba78abc6c2f71f7773393a11
4
+ data.tar.gz: 511be708c002602adb73dd8875b59eef83e7030340904cb1cde25f625ad5f08d
5
5
  SHA512:
6
- metadata.gz: 3073813fd46d908597a3ccbe2346cc0b21183602263531993bcb07f7615024c95e7d50583e60bf915af1e3d7f60361c6f23d230f61ebc072c680ced4db444b10
7
- data.tar.gz: 9aeba75a355fa2e5a66ae238e2f1b28eefbcfea6af453e30dbf090d030e88051c9e7c7f1a97d74fb9764ff4a0a6f0ab472234da0da167c03d49bb54a4d06d7cb
6
+ metadata.gz: 12a2d48080c2e790f1df127f1d0610c68b40ae86e7f546b65594c7580bac69f622d484fe8b4e596fcac732e0c0b89ae501722d4e3ef2709faa29320416afb2ec
7
+ data.tar.gz: 156d45d57be65190824d54bc77154f46f7a9440672698793f484d61f7d56a10a14e4f2317b1d21c8364fd8444f92c4cd9a8abb3d42de395a1de5f1a53f49fe97
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ Layout/EmptyLineAfterMagicComment:
4
+ AutoCorrect: true
5
+ Style/FrozenStringLiteralComment:
6
+ AutoCorrect: true
7
+ Style/StringLiterals:
8
+ AutoCorrect: true
9
+ Style/ClassAndModuleChildren:
10
+ AutoCorrect: true
11
+ Style/HashSyntax:
12
+ AutoCorrect: true
13
+ Style/HashEachMethods:
14
+ Enabled: true
15
+ Style/HashTransformKeys:
16
+ Enabled: true
17
+ Style/HashTransformValues:
18
+ Enabled: true
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
3
+ - 2.7.0
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # devise_specs
2
2
 
3
- devise_specs is a Rails generator that adds the Devise authentication acceptance tests when you run the `devise` generator. The tests are RSpec feature specs containing Factory Bot or Fabrication fixture replacement methods and Capybara actions.
3
+ Drop-in upgrade of legacy `devise-specs` gem.
4
+
5
+ `devise_specs` is a Rails generator that adds the Devise authentication acceptance tests when you run the `devise` generator. The tests are RSpec feature specs containing Factory Bot or Fabrication fixture replacement methods and Capybara actions.
4
6
 
5
7
  Generated feature specs test the following features:
6
8
  * Registration
@@ -36,12 +38,12 @@ and then run `bundle install`.
36
38
 
37
39
  Generate the RSpec configuratoin files:
38
40
  ```
39
- $ rails generate rspec:install
41
+ $ bundle exec rails generate rspec:install
40
42
  ```
41
43
 
42
44
  Generate the Devise configuration files and follow the setup instructions to define the default url options, root route and flash messages:
43
45
  ```
44
- $ rails generate devise:install
46
+ $ bundle exec rails generate devise:install
45
47
  ```
46
48
 
47
49
  Configure the Action Mailer URL options for the test environment using the following line in `config/environments/test.rb`:
@@ -49,21 +51,139 @@ Configure the Action Mailer URL options for the test environment using the follo
49
51
  config.action_mailer.default_url_options = { host: 'localhost', port: 3001 }
50
52
  ```
51
53
 
52
- Add the authentication links to the layout, `user_signed_in?` should be `admin_signed_in?` if your Devise model is `Admin`:
54
+ Add the authentication links to the layout in `app/views/layouts/application.html.erb`, `user_signed_in?` should be `admin_signed_in?` if your Devise model is `Admin`:
53
55
  ```erb
56
+ <%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
57
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
58
+ </head>
59
+
60
+ <body>
61
+ <p class='notice'><%= notice %></p>
62
+ <p class='alert'><%= alert %></p>
63
+ <ul class="hmenu">
64
+ <%= render 'devise/menu/account_items' %>
65
+ </ul>
66
+ <%= yield %>
67
+ </body>
68
+
69
+ ```
70
+
71
+ In `app/views/devise/menu/_account_items.html.erb`, please add:
72
+ ```ruby
54
73
  <% if user_signed_in? %>
55
- <%= link_to 'Sign Out', destroy_user_session_path, method: :delete %>
74
+ <li>
75
+ <%= link_to('Edit registration', edit_user_registration_path) %>
76
+ </li>
77
+ <li>
78
+ <%= link_to('Sign out', destroy_user_session_path, method: :delete) %>
79
+ </li>
56
80
  <% else %>
57
- <%= link_to 'Sign In', new_user_session_path %>
58
- <%= link_to 'Sign Up', new_user_registration_path %>
81
+ <li>
82
+ <%- if controller_name != 'sessions' %>
83
+ <%= link_to 'Sign in', new_session_path(resource_name) %>
84
+ <% end %>
85
+ </li>
86
+ <li>
87
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
88
+ <%= link_to 'Create an account', new_registration_path(resource_name) %><br />
89
+ <% end %>
90
+ </li>
59
91
  <% end %>
92
+
93
+ ```
94
+
95
+ In `app/views/devise/shared/_links.html.erb`, verify you only have the following:
96
+ ```ruby
97
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
98
+ <%= link_to 'Forgot your password?', new_password_path(resource_name) %><br />
99
+ <% end %>
100
+
101
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
102
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
103
+ <% end %>
104
+
105
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
106
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
107
+ <% end %>
108
+
109
+ <%- if devise_mapping.omniauthable? %>
110
+ <%- resource_class.omniauth_providers.each do |provider| %>
111
+ <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
112
+ <% end %>
113
+ <% end %>
114
+
115
+ ```
116
+
117
+ In `app/views/devise/sessions/new.html.erb`, add:
118
+ ```ruby
119
+ <h2>Sign in</h2>
120
+
121
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
122
+ <div class="field">
123
+ <%= f.label :email %><br />
124
+ <%= f.email_field :email, autofocus: true, autocomplete: 'email' %>
125
+ </div>
126
+
127
+ <div class="field">
128
+ <%= f.label :password %><br />
129
+ <%= f.password_field :password, autocomplete: 'current-password' %>
130
+ </div>
131
+
132
+ <% if devise_mapping.rememberable? %>
133
+ <div class="field">
134
+ <%= f.check_box :remember_me %>
135
+ <%= f.label :remember_me %>
136
+ </div>
137
+ <% end %>
138
+
139
+ <div class="actions">
140
+ <%= f.submit 'Sign in' %>
141
+ </div>
142
+ <% end %>
143
+
144
+ <%= render 'devise/shared/links' %>
145
+
146
+ ```
147
+
148
+ In `app/views/devise/registrations/new.html.erb`, add:
149
+ ```ruby
150
+ <h2>Create your Account</h2>
151
+
152
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
153
+ <%= render 'devise/shared/error_messages', resource: resource %>
154
+
155
+ <div class="field">
156
+ <%= f.label :email %><br />
157
+ <%= f.email_field :email, autofocus: true, autocomplete: 'email' %>
158
+ </div>
159
+
160
+ <div class="field">
161
+ <%= f.label :password %>
162
+ <% if @minimum_password_length %>
163
+ <em>(<%= @minimum_password_length %> characters minimum)</em>
164
+ <% end %><br />
165
+ <%= f.password_field :password, autocomplete: 'new-password' %>
166
+ </div>
167
+
168
+ <div class="field">
169
+ <%= f.label :password_confirmation %><br />
170
+ <%= f.password_field :password_confirmation, autocomplete: 'new-password' %>
171
+ </div>
172
+
173
+ <div class="actions">
174
+ <%= f.submit 'Create Account' %>
175
+ </div>
176
+ <% end %>
177
+
178
+ <%= render 'devise/shared/links' %>
179
+
60
180
  ```
61
181
 
62
182
  ## Usage
63
183
 
64
184
  Specs are created automatically when you generate a Devise model, e.g. `User`:
65
185
  ```
66
- $ rails generate devise User
186
+ $ bundle exec rails generate devise User
67
187
  ...
68
188
  invoke specs
69
189
  gsub spec/rails_helper.rb
@@ -78,7 +198,7 @@ $ rails generate devise User
78
198
 
79
199
  If a Devise model is already present, run the `devise:specs` generator directly:
80
200
  ```
81
- $ rails generate devise:specs User
201
+ $ bundle exec rails generate devise:specs User
82
202
  ```
83
203
 
84
204
  Run the migrations:
@@ -91,13 +211,14 @@ Make sure the specs pass:
91
211
  $ rspec spec/features
92
212
  .........
93
213
 
94
- Finished in 1.08 seconds (files took 2.1 seconds to load)
214
+ Finished in 0.93371 seconds (files took 1.88 seconds to load)
95
215
  9 examples, 0 failures
216
+
96
217
  ```
97
218
 
98
219
  ## Documentation
99
220
 
100
- Visit the [Relish docs](https://relishapp.com/andrii/devise_specs/docs) for all the available features and examples of the generated feature specs.
221
+ Visit the [Relish docs](https://relishapp.com/andrii/devise_specs/docs) for all the available features and legacy examples of the generated feature specs.
101
222
 
102
223
  ## Output
103
224
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/rake/task'
2
4
 
3
5
  Cucumber::Rake::Task.new
data/devise_specs.gemspec CHANGED
@@ -1,17 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'devise_specs'
3
- s.version = '0.0.5'
5
+ s.version = '0.0.7'
4
6
  s.authors = ["Gaspard d'Hautefeuille"]
5
7
  s.email = 'ruby@dhautefeuille.eu'
6
- s.summary = 'Generates the Devise acceptance tests.'
8
+ s.summary = 'Drop-in upgrade of legacy devise-specs gem. Generates the Devise acceptance tests for Rails 6+.'
7
9
  s.homepage = 'https://github.com/HLFH/devise_specs'
8
10
  s.license = 'MIT'
9
11
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features|fixtures)/}) }
10
-
11
- s.required_ruby_version = '>= 2.6.5'
12
+
13
+ s.required_ruby_version = '>= 2.7'
12
14
 
13
15
  s.add_runtime_dependency 'devise', '~> 4.7', '>= 4.7.1'
14
16
 
15
- s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
16
17
  s.add_development_dependency 'aruba', '~> 1.0'
18
+ s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
17
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Specs
3
5
  class Railtie < Rails::Railtie
data/lib/devise_specs.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/specs/railtie'
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Generators
3
5
  class SpecsGenerator < Rails::Generators::NamedBase
4
6
  ATTRIBUTES = %(
5
- email 'username@example.com'
6
- password 'password')
7
+ email { 'username@example.com' }
8
+ password { 'password' })
7
9
 
8
- source_root File.expand_path("../templates", __FILE__)
10
+ source_root File.expand_path('templates', __dir__)
9
11
 
10
12
  def require_supporting_files
11
13
  uncomment_lines 'spec/rails_helper.rb', /spec.support.*rb.*require/
@@ -52,19 +54,21 @@ module Devise
52
54
  end
53
55
 
54
56
  def insert_factory_bot_attributes
55
- path = "spec/factories/#{plural_name}.rb"
56
- attrs = ATTRIBUTES.gsub(/^ {4}/, '')
57
- data = "factory :#{singular_name} do"
57
+ frozen = "# frozen_string_literal: true\n\n"
58
+ path = "spec/factories/#{plural_name}.rb"
59
+ attrs = "#{ATTRIBUTES.gsub(/^ {4}/, '')}\n end\nend\n"
60
+ data = "FactoryBot.define do\n factory :#{singular_name} do"
58
61
 
59
- create_file path, data + attrs
62
+ create_file path, frozen + data + attrs
60
63
  end
61
64
 
62
65
  def insert_fabrication_attributes
63
- path = "spec/fabricators/#{singular_name}_fabricator.rb"
64
- attrs = ATTRIBUTES.gsub(/^ {6}/, '')
66
+ frozen = "# frozen_string_literal: true\n\n"
67
+ path = "spec/fabricators/#{singular_name}_fabricator.rb"
68
+ attrs = "#{ATTRIBUTES.gsub(/^ {6}/, '')}\nend\n"
65
69
  after = "Fabricator(:#{singular_name}) do"
66
70
 
67
- create_file path, data + attrs
71
+ create_file path, frozen + data + attrs
68
72
  end
69
73
  end
70
74
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.include Devise::Test::IntegrationHelpers, type: :feature
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.include FactoryBot::Syntax::Methods
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  feature '<%= human_name %> resets a password' do
@@ -40,7 +42,7 @@ feature '<%= human_name %> resets a password' do
40
42
  click_button 'Change my password'
41
43
 
42
44
  expect(page).to have_text 'Your password has been changed successfully.'
43
- expect(page).to have_current_path root_path
45
+ expect(page).to have_current_path authenticated_root_path
44
46
  end
45
47
 
46
48
  scenario 'password reset token is invalid' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  feature '<%= human_name %> signs in' do
@@ -12,11 +14,11 @@ feature '<%= human_name %> signs in' do
12
14
 
13
15
  fill_in 'Email', with: <%= singular_name %>.email
14
16
  fill_in 'Password', with: <%= singular_name %>.password
15
- click_button 'Log in'
17
+ click_button 'Sign in'
16
18
 
17
19
  expect(page).to have_text 'Signed in successfully.'
18
- expect(page).to have_link 'Sign Out'
19
- expect(page).to have_current_path root_path
20
+ expect(page).to have_link 'Sign out'
21
+ expect(page).to have_current_path authenticated_root_path
20
22
  end
21
23
 
22
24
  scenario 'with invalid credentials' do
@@ -30,9 +32,9 @@ feature '<%= human_name %> signs in' do
30
32
 
31
33
  fill_in 'Email', with: <%= singular_name %>.email
32
34
  fill_in 'Password', with: <%= singular_name %>.password
33
- click_button 'Log in'
35
+ click_button 'Sign in'
34
36
 
35
37
  expect(page).to have_text 'Invalid Email or password.'
36
- expect(page).to have_no_link 'Sign Out'
38
+ expect(page).to have_no_link 'Sign out'
37
39
  end
38
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  feature '<%= human_name %> signs out' do
@@ -10,12 +12,12 @@ feature '<%= human_name %> signs out' do
10
12
 
11
13
  sign_in <%= singular_name %>
12
14
 
13
- visit root_path
15
+ visit authenticated_root_path
14
16
 
15
- click_link 'Sign Out'
17
+ click_link 'Sign out'
16
18
 
17
19
  expect(page).to have_text 'Signed out successfully.'
18
- expect(page).to have_no_link 'Sign Out'
19
- expect(page).to have_current_path root_path
20
+ expect(page).to have_no_link 'Sign out'
21
+ expect(page).to have_current_path unauthenticated_root_path
20
22
  end
21
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_helper'
2
4
 
3
5
  feature '<%= human_name %> signs up' do
@@ -7,20 +9,20 @@ feature '<%= human_name %> signs up' do
7
9
  fill_in 'Email', with: 'username@example.com'
8
10
  fill_in 'Password', with: 'password'
9
11
  fill_in 'Password confirmation', with: 'password'
10
- click_button 'Sign up'
12
+ click_button 'Create Account'
11
13
 
12
14
  expect(page).to have_text 'Welcome! You have signed up successfully.'
13
- expect(page).to have_link 'Sign Out'
14
- expect(page).to have_current_path root_path
15
+ expect(page).to have_link 'Sign out'
16
+ expect(page).to have_current_path authenticated_root_path
15
17
  end
16
18
 
17
19
  scenario 'with invalid data' do
18
20
  visit new_<%= singular_name %>_registration_path
19
21
 
20
- click_button 'Sign up'
22
+ click_button 'Create Account'
21
23
 
22
24
  expect(page).to have_text "Email can't be blank"
23
25
  expect(page).to have_text "Password can't be blank"
24
- expect(page).to have_no_link 'Sign Out'
26
+ expect(page).to have_no_link 'Sign out'
25
27
  end
26
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_specs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaspard d'Hautefeuille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -31,39 +31,39 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.7.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: rake
34
+ name: aruba
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '13.0'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 13.0.1
39
+ version: '1.0'
43
40
  type: :development
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
44
  - - "~>"
48
45
  - !ruby/object:Gem::Version
49
- version: '13.0'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 13.0.1
46
+ version: '1.0'
53
47
  - !ruby/object:Gem::Dependency
54
- name: aruba
48
+ name: rake
55
49
  requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
51
  - - "~>"
58
52
  - !ruby/object:Gem::Version
59
- version: '1.0'
53
+ version: '13.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 13.0.1
60
57
  type: :development
61
58
  prerelease: false
62
59
  version_requirements: !ruby/object:Gem::Requirement
63
60
  requirements:
64
61
  - - "~>"
65
62
  - !ruby/object:Gem::Version
66
- version: '1.0'
63
+ version: '13.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 13.0.1
67
67
  description:
68
68
  email: ruby@dhautefeuille.eu
69
69
  executables: []
@@ -72,6 +72,7 @@ extra_rdoc_files: []
72
72
  files:
73
73
  - ".codeclimate.yml"
74
74
  - ".gitignore"
75
+ - ".rubocop.yml"
75
76
  - ".travis.yml"
76
77
  - CHANGELOG.md
77
78
  - Gemfile
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="
101
102
  - !ruby/object:Gem::Version
102
- version: 2.6.5
103
+ version: '2.7'
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  requirements:
105
106
  - - ">="
@@ -109,5 +110,6 @@ requirements: []
109
110
  rubygems_version: 3.1.2
110
111
  signing_key:
111
112
  specification_version: 4
112
- summary: Generates the Devise acceptance tests.
113
+ summary: Drop-in upgrade of legacy devise-specs gem. Generates the Devise acceptance
114
+ tests for Rails 6+.
113
115
  test_files: []