devise-specs 0.0.1 → 0.0.5

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
- SHA1:
3
- metadata.gz: 6effecf1c766dc1b0a188e9f18bdb48f8767e553
4
- data.tar.gz: feb9ba88290c49452a30ced186dee6d3b93a0ac0
2
+ SHA256:
3
+ metadata.gz: be3f6fffcdfd6745c53813e98dff18e028631f927693c9632a81366d2d5ef8f0
4
+ data.tar.gz: 7134709344aab0354ac0d041d7222fc808674cfda488791ee9edf8f7c9b0adc2
5
5
  SHA512:
6
- metadata.gz: c44eeab458aa434a7487a668aaa9e1ce86f475a57ef982a7e24a99a2705067b21c8adcfa014dba39a64eb6e54f9a381ec755b66a5042b3040ab5627b0d7ef928
7
- data.tar.gz: e8785b973c23cdb527d3d3713a4eccae2c0b0ad0cc34d6454ed4309b99e3bd9668753898ff2f779edba225d49fe1dcd4c350da1f5c573e92ea6895a510d45fb6
6
+ metadata.gz: d2c8a1bf622e860236e2a6e7a61e22d6e0574833d83d8ed407c89d3038af38cf63861395444677ffadefd790fc2e6eec7cf2bb93722b24329cb5be74c3ca7c71
7
+ data.tar.gz: 928a9d44fe9db4918a0631cdde7eaed7ee98893ea471f0a6ad9a96c2440a89d089ab02a61102edc3276799e7c8d0a66111998320ea72f6b99d76a470dd1acefa
@@ -0,0 +1,26 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.6', '2.7']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ - name: Bundle install
24
+ run: bundle install
25
+ - name: Run tests
26
+ run: bundle exec rake
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ ### 0.0.5
2
+
3
+ * Support latest Factory Bot and RSpec Rails versions
4
+
5
+ ### 0.0.4
6
+
7
+ * Make internal tests pass on Rails 5.1 and clean up docs
8
+
9
+
10
+ ### 0.0.3
11
+
12
+ * Use the new `Devise::Test::IntegrationHelpers` instead of the custom `sign_in` helper
13
+
14
+ ### 0.0.2
15
+
16
+ * Add more thorough expectations to generated specs
17
+ * Rename specs:devise generator to devise:specs
18
+ * Update README with Output and Testing sections
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
- # devise-specs
1
+ # devise-specs [![Build Status][ci-image]][ci] [![Maintainability][grade-image]][grade]
2
2
 
3
- [![Build Status](https://travis-ci.org/andrii/devise-specs.svg?branch=master)](https://travis-ci.org/andrii/devise-specs)
4
- [![Code Climate](https://codeclimate.com/github/andrii/devise-specs/badges/gpa.svg)](https://codeclimate.com/github/andrii/devise-specs)
5
-
6
- 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 Girl or Fabricatoin fixture replacement methods and Capybara actions.
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.
7
4
 
8
5
  Generated feature specs test the following features:
9
6
  * Registration
@@ -11,11 +8,9 @@ Generated feature specs test the following features:
11
8
  * Logout
12
9
  * Password reset
13
10
 
14
- Works with Rails 4 and 5.
15
-
16
11
  ## Installation
17
12
 
18
- Specify the required dependencies in a `Gemfile`:
13
+ Make sure `devise`, `devise-specs`, `rspec-rails`, `capybara` and fixture replacement gems are added to the `Gemfile`:
19
14
  ```ruby
20
15
  gem 'devise'
21
16
 
@@ -29,7 +24,7 @@ end
29
24
 
30
25
  group :development, :test do
31
26
  gem 'rspec-rails'
32
- gem 'factory_girl_rails' # or: gem 'fabrication'
27
+ gem 'factory_bot_rails' # or: gem 'fabrication'
33
28
  end
34
29
  ```
35
30
 
@@ -39,12 +34,12 @@ and then run `bundle install`.
39
34
 
40
35
  Generate the RSpec configuratoin files:
41
36
  ```
42
- $ rails generate rspec:install
37
+ $ bin/rails generate rspec:install
43
38
  ```
44
39
 
45
- Generate the Devise configuration files and follow the setup instructions:
40
+ Generate the Devise configuration files and follow the setup instructions to define the default url options, root route and flash messages:
46
41
  ```
47
- $ rails generate devise:install
42
+ $ bin/rails generate devise:install
48
43
  ```
49
44
 
50
45
  Configure the Action Mailer URL options for the test environment using the following line in `config/environments/test.rb`:
@@ -62,33 +57,31 @@ Add the authentication links to the layout, `user_signed_in?` should be `admin_s
62
57
  <% end %>
63
58
  ```
64
59
 
65
- Add the following lines to `config/application.rb` if you are using the Fabrication gem and gem version is less than 2.15.1:
66
- ```ruby
67
- config.generators do |g|
68
- g.fixture_replacement :fabrication
69
- end
70
- ```
71
-
72
60
  ## Usage
73
61
 
74
- Generate a Devise model, e.g. `User`:
62
+ Specs are created automatically when you generate a Devise model, e.g. `User`:
75
63
  ```
76
- $ rails generate devise User
64
+ $ bin/rails generate devise User
77
65
  ...
78
66
  invoke specs
79
67
  gsub spec/rails_helper.rb
80
68
  insert spec/factories/users.rb
81
- create spec/support/factory_girl.rb
82
- create spec/support/helpers.rb
69
+ create spec/support/factory_bot.rb
70
+ create spec/support/devise.rb
83
71
  create spec/features/user_signs_up_spec.rb
84
72
  create spec/features/user_signs_in_spec.rb
85
73
  create spec/features/user_signs_out_spec.rb
86
74
  create spec/features/user_resets_password_spec.rb
87
75
  ```
88
76
 
77
+ If a Devise model is already present, run the `devise:specs` generator directly:
78
+ ```
79
+ $ bin/rails generate devise:specs User
80
+ ```
81
+
89
82
  Run the migrations:
90
83
  ```
91
- $ rake db:migrate RAILS_ENV=test
84
+ $ bin/rails db:migrate RAILS_ENV=test
92
85
  ```
93
86
 
94
87
  Make sure the specs pass:
@@ -104,6 +97,44 @@ Finished in 1.08 seconds (files took 2.1 seconds to load)
104
97
 
105
98
  Visit the [Relish docs](https://relishapp.com/andrii/devise-specs/docs) for all the available features and examples of the generated feature specs.
106
99
 
100
+ ## Output
101
+
102
+ `gsub spec/rails_helper.rb`
103
+
104
+ Uncomments the line that auto-requires all files in the support directory.
105
+
106
+ `insert spec/fabricators/*_fabricator.rb`
107
+
108
+ Adds `email` and `password` attributes to the fabricator.
109
+
110
+ `insert spec/factories/*.rb`
111
+
112
+ Adds `email` and `password` attributes to the factory.
113
+
114
+ `create spec/support/factory_bot.rb`
115
+
116
+ Includes `FactoryBot::Syntax::Methods` into RSpec config to avoid prefacing Factory Bot methods with `FactoryBot`.
117
+
118
+ `create spec/support/devise.rb`
119
+
120
+ Includes Devise integration test helpers into feature specs.
121
+
122
+ `create spec/features/*_spec.rb`
123
+
124
+ Generates a corresponding feature spec.
125
+
126
+ ## Testing
127
+
128
+ Install system and development dependencies and run the tests:
129
+ ```
130
+ $ bundle exec rake
131
+ ```
132
+
107
133
  ## License
108
134
 
109
135
  MIT License
136
+
137
+ [ci-image]: https://github.com/ponosoft/devise-specs/actions/workflows/build.yml/badge.svg
138
+ [ci]: https://github.com/ponosoft/devise-specs/actions/workflows/build.yml
139
+ [grade-image]: https://api.codeclimate.com/v1/badges/b7e541f2f5171790638f/maintainability
140
+ [grade]: https://codeclimate.com/github/ponosoft/devise-specs/maintainability
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --publish-quiet
data/devise-specs.gemspec CHANGED
@@ -1,15 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'devise-specs'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.5'
4
4
  s.authors = ['Andrii Ponomarov']
5
5
  s.email = 'andrii.ponomarov@gmail.com'
6
6
  s.summary = 'Generates the Devise acceptance tests.'
7
- s.homepage = 'https://github.com/andrii/devise-specs'
7
+ s.homepage = 'https://github.com/ponosoft/devise-specs'
8
8
  s.license = 'MIT'
9
9
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features|fixtures)/}) }
10
10
 
11
- s.add_runtime_dependency 'devise', '~> 4.1'
11
+ s.required_ruby_version = '>= 2.5.0'
12
12
 
13
- s.add_development_dependency 'rake', '~> 11.1'
14
- s.add_development_dependency 'aruba', '~> 0.14.1'
13
+ s.add_runtime_dependency 'devise', '~> 4.8'
14
+
15
+ s.add_development_dependency 'aruba', '~> 1.1', '>= 1.1.2'
16
+ s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
15
17
  end
@@ -1,34 +1,35 @@
1
- module Specs
1
+ module Devise
2
2
  module Generators
3
- class DeviseGenerator < Rails::Generators::NamedBase
3
+ class SpecsGenerator < Rails::Generators::NamedBase
4
4
  ATTRIBUTES = %(
5
- email 'username@example.com'
6
- password 'password')
5
+ email { 'username@example.com' }
6
+ password { 'password' }
7
+ ).freeze
7
8
 
8
- source_root File.expand_path("../templates", __FILE__)
9
+ source_root File.expand_path('../templates', __FILE__)
9
10
 
10
- def require_supporting_files
11
- uncomment_lines 'spec/rails_helper.rb', /spec.support.*rb.*require/
11
+ def require_support_files
12
+ uncomment_lines 'spec/rails_helper.rb', /spec.*support.*rb.*require/
12
13
  end
13
14
 
14
15
  def insert_fixture_replacement_attributes
15
16
  return if behavior == :revoke
16
17
 
17
- if fixture_replacement == :factory_girl
18
- insert_factory_girl_attributes
18
+ if fixture_replacement == :factory_bot
19
+ insert_factory_bot_attributes
19
20
  elsif fixture_replacement == :fabrication
20
21
  insert_fabrication_attributes
21
22
  end
22
23
  end
23
24
 
24
- def create_factory_girl_config_file
25
- if fixture_replacement == :factory_girl
26
- template 'factory_girl.rb', 'spec/support/factory_girl.rb'
25
+ def create_factory_bot_config_file
26
+ if fixture_replacement == :factory_bot
27
+ template 'factory_bot.rb', 'spec/support/factory_bot.rb'
27
28
  end
28
29
  end
29
30
 
30
- def create_helpers_file
31
- template 'helpers.rb', 'spec/support/helpers.rb'
31
+ def create_devise_config_file
32
+ template 'devise.rb', 'spec/support/devise.rb'
32
33
  end
33
34
 
34
35
  def create_specs
@@ -51,7 +52,7 @@ module Specs
51
52
  Rails.application.config.generators.rails[:fixture_replacement]
52
53
  end
53
54
 
54
- def insert_factory_girl_attributes
55
+ def insert_factory_bot_attributes
55
56
  path = "spec/factories/#{plural_name}.rb"
56
57
  attrs = ATTRIBUTES.gsub(/^ {4}/, '')
57
58
  after = "factory :#{singular_name} do"
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Devise::Test::IntegrationHelpers, type: :feature
3
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryBot::Syntax::Methods
3
+ end
@@ -1,8 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
- feature '<%= human_name %> resets a password' do
3
+ RSpec.feature '<%= human_name %> resets a password' do
4
4
  scenario '<%= singular_name %> enters a valid email' do
5
- <% if fixture_replacement == :factory_girl -%>
5
+ <% if fixture_replacement == :factory_bot -%>
6
6
  <%= singular_name %> = create :<%= singular_name %>
7
7
  <% elsif fixture_replacement == :fabrication -%>
8
8
  <%= singular_name %> = Fabricate :<%= singular_name %>
@@ -14,6 +14,7 @@ feature '<%= human_name %> resets a password' do
14
14
  click_button 'Send me reset password instructions'
15
15
 
16
16
  expect(page).to have_text 'You will receive an email with instructions'
17
+ expect(page).to have_current_path new_<%= singular_name %>_session_path
17
18
  end
18
19
 
19
20
  scenario '<%= singular_name %> enters an invalid email' do
@@ -26,7 +27,7 @@ feature '<%= human_name %> resets a password' do
26
27
  end
27
28
 
28
29
  scenario '<%= singular_name %> changes password' do
29
- <% if fixture_replacement == :factory_girl -%>
30
+ <% if fixture_replacement == :factory_bot -%>
30
31
  token = create(:<%= singular_name %>).send_reset_password_instructions
31
32
  <% elsif fixture_replacement == :fabrication -%>
32
33
  token = Fabricate(:<%= singular_name %>).send_reset_password_instructions
@@ -39,6 +40,7 @@ feature '<%= human_name %> resets a password' do
39
40
  click_button 'Change my password'
40
41
 
41
42
  expect(page).to have_text 'Your password has been changed successfully.'
43
+ expect(page).to have_current_path root_path
42
44
  end
43
45
 
44
46
  scenario 'password reset token is invalid' do
@@ -0,0 +1,38 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.feature '<%= human_name %> signs in' do
4
+ scenario 'with valid credentials' do
5
+ <% if fixture_replacement == :factory_bot -%>
6
+ <%= singular_name %> = create :<%= singular_name %>
7
+ <% elsif fixture_replacement == :fabrication -%>
8
+ <%= singular_name %> = Fabricate :<%= singular_name %>
9
+ <% end -%>
10
+
11
+ visit new_<%= singular_name %>_session_path
12
+
13
+ fill_in 'Email', with: <%= singular_name %>.email
14
+ fill_in 'Password', with: <%= singular_name %>.password
15
+ click_button 'Log in'
16
+
17
+ 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
+ end
21
+
22
+ scenario 'with invalid credentials' do
23
+ <% if fixture_replacement == :factory_bot -%>
24
+ <%= singular_name %> = build :<%= singular_name %>
25
+ <% elsif fixture_replacement == :fabrication -%>
26
+ <%= singular_name %> = Fabricate.build :<%= singular_name %>
27
+ <% end -%>
28
+
29
+ visit new_<%= singular_name %>_session_path
30
+
31
+ fill_in 'Email', with: <%= singular_name %>.email
32
+ fill_in 'Password', with: <%= singular_name %>.password
33
+ click_button 'Log in'
34
+
35
+ expect(page).to have_text 'Invalid Email or password.'
36
+ expect(page).to have_no_link 'Sign Out'
37
+ end
38
+ end
@@ -1,8 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
- feature '<%= human_name %> signs out' do
3
+ RSpec.feature '<%= human_name %> signs out' do
4
4
  scenario '<%= singular_name %> signed in' do
5
- <% if fixture_replacement == :factory_girl -%>
5
+ <% if fixture_replacement == :factory_bot -%>
6
6
  <%= singular_name %> = create :<%= singular_name %>
7
7
  <% elsif fixture_replacement == :fabrication -%>
8
8
  <%= singular_name %> = Fabricate :<%= singular_name %>
@@ -10,8 +10,12 @@ feature '<%= human_name %> signs out' do
10
10
 
11
11
  sign_in <%= singular_name %>
12
12
 
13
+ visit root_path
14
+
13
15
  click_link 'Sign Out'
14
16
 
15
17
  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
16
20
  end
17
21
  end
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- feature '<%= human_name %> signs up' do
3
+ RSpec.feature '<%= human_name %> signs up' do
4
4
  scenario 'with valid data' do
5
5
  visit new_<%= singular_name %>_registration_path
6
6
 
@@ -10,6 +10,8 @@ feature '<%= human_name %> signs up' do
10
10
  click_button 'Sign up'
11
11
 
12
12
  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
13
15
  end
14
16
 
15
17
  scenario 'with invalid data' do
@@ -19,5 +21,6 @@ feature '<%= human_name %> signs up' do
19
21
 
20
22
  expect(page).to have_text "Email can't be blank"
21
23
  expect(page).to have_text "Password can't be blank"
24
+ expect(page).to have_no_link 'Sign Out'
22
25
  end
23
26
  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.1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrii Ponomarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
11
+ date: 2021-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -16,65 +16,78 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '4.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: '4.8'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: aruba
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '11.1'
33
+ version: '1.1'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.1.2
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '11.1'
43
+ version: '1.1'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.1.2
41
47
  - !ruby/object:Gem::Dependency
42
- name: aruba
48
+ name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 0.14.1
53
+ version: '13.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 13.0.6
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
61
  - - "~>"
53
62
  - !ruby/object:Gem::Version
54
- version: 0.14.1
63
+ version: '13.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 13.0.6
55
67
  description:
56
68
  email: andrii.ponomarov@gmail.com
57
69
  executables: []
58
70
  extensions: []
59
71
  extra_rdoc_files: []
60
72
  files:
61
- - ".codeclimate.yml"
73
+ - ".github/workflows/build.yml"
62
74
  - ".gitignore"
63
- - ".travis.yml"
75
+ - CHANGELOG.md
64
76
  - Gemfile
65
77
  - README.md
66
78
  - Rakefile
79
+ - cucumber.yml
67
80
  - devise-specs.gemspec
68
81
  - lib/devise-specs.rb
69
82
  - lib/devise/specs/railtie.rb
70
- - lib/generators/specs/devise_generator.rb
71
- - lib/generators/specs/templates/factory_girl.rb.tt
72
- - lib/generators/specs/templates/helpers.rb.tt
73
- - lib/generators/specs/templates/resource_resets_password_spec.rb.tt
74
- - lib/generators/specs/templates/resource_signs_in_spec.rb.tt
75
- - lib/generators/specs/templates/resource_signs_out_spec.rb.tt
76
- - lib/generators/specs/templates/resource_signs_up_spec.rb.tt
77
- homepage: https://github.com/andrii/devise-specs
83
+ - lib/generators/devise/specs_generator.rb
84
+ - lib/generators/devise/templates/devise.rb.tt
85
+ - lib/generators/devise/templates/factory_bot.rb.tt
86
+ - lib/generators/devise/templates/resource_resets_password_spec.rb.tt
87
+ - lib/generators/devise/templates/resource_signs_in_spec.rb.tt
88
+ - lib/generators/devise/templates/resource_signs_out_spec.rb.tt
89
+ - lib/generators/devise/templates/resource_signs_up_spec.rb.tt
90
+ homepage: https://github.com/ponosoft/devise-specs
78
91
  licenses:
79
92
  - MIT
80
93
  metadata: {}
@@ -86,15 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
99
  requirements:
87
100
  - - ">="
88
101
  - !ruby/object:Gem::Version
89
- version: '0'
102
+ version: 2.5.0
90
103
  required_rubygems_version: !ruby/object:Gem::Requirement
91
104
  requirements:
92
105
  - - ">="
93
106
  - !ruby/object:Gem::Version
94
107
  version: '0'
95
108
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.5.1
109
+ rubygems_version: 3.1.6
98
110
  signing_key:
99
111
  specification_version: 4
100
112
  summary: Generates the Devise acceptance tests.
data/.codeclimate.yml DELETED
@@ -1,18 +0,0 @@
1
- ---
2
- engines:
3
- duplication:
4
- enabled: true
5
- config:
6
- languages:
7
- - ruby
8
- exclude_fingerprints:
9
- - 9f7a179915ee4a7f1d639e9242aedd01
10
- fixme:
11
- enabled: true
12
- rubocop:
13
- enabled: true
14
- ratings:
15
- paths:
16
- - "**.rb"
17
- exclude_paths:
18
- - features/
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.1
@@ -1,3 +0,0 @@
1
- RSpec.configure do |config|
2
- config.include FactoryGirl::Syntax::Methods
3
- end
@@ -1,13 +0,0 @@
1
- module Helpers
2
- def sign_in(resource)
3
- visit new_<%= singular_name %>_session_path
4
-
5
- fill_in 'Email', with: resource.email
6
- fill_in 'Password', with: resource.password
7
- click_button 'Log in'
8
- end
9
- end
10
-
11
- RSpec.configure do |config|
12
- config.include Helpers, type: :feature
13
- end
@@ -1,27 +0,0 @@
1
- require 'rails_helper'
2
-
3
- feature '<%= human_name %> signs in' do
4
- scenario 'with valid credentials' do
5
- <% if fixture_replacement == :factory_girl -%>
6
- <%= singular_name %> = create :<%= singular_name %>
7
- <% elsif fixture_replacement == :fabrication -%>
8
- <%= singular_name %> = Fabricate :<%= singular_name %>
9
- <% end -%>
10
-
11
- sign_in <%= singular_name %>
12
-
13
- expect(page).to have_text 'Signed in successfully.'
14
- end
15
-
16
- scenario 'with invalid credentials' do
17
- <% if fixture_replacement == :factory_girl -%>
18
- <%= singular_name %> = build :<%= singular_name %>
19
- <% elsif fixture_replacement == :fabrication -%>
20
- <%= singular_name %> = Fabricate.build :<%= singular_name %>
21
- <% end -%>
22
-
23
- sign_in <%= singular_name %>
24
-
25
- expect(page).to have_text 'Invalid Email or password.'
26
- end
27
- end