g5_authenticatable 0.9.1.pre.2 → 1.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +23 -9
- data/Appraisals +17 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +11 -14
- data/README.md +40 -13
- data/app/controllers/concerns/g5_authenticatable/authorization.rb +4 -1
- data/app/controllers/g5_authenticatable/application_controller.rb +3 -0
- data/app/controllers/g5_authenticatable/error_controller.rb +3 -2
- data/app/controllers/g5_authenticatable/failure_app.rb +35 -0
- data/app/controllers/g5_authenticatable/sessions_controller.rb +7 -3
- data/app/helpers/g5_authenticatable/application_helper.rb +3 -0
- data/app/models/g5_authenticatable/role.rb +5 -2
- data/app/models/g5_authenticatable/user.rb +12 -5
- data/app/policies/g5_authenticatable/base_policy.rb +75 -58
- data/app/policies/g5_updatable/client_policy.rb +5 -5
- data/app/policies/g5_updatable/location_policy.rb +6 -5
- data/app/policies/g5_updatable/selectable_client_policy.rb +6 -7
- data/app/services/g5_authenticatable/impersonate_sessionable.rb +12 -7
- data/config/initializers/devise.rb +4 -0
- data/config/initializers/impersonate_strategy.rb +5 -2
- data/config/initializers/rolify.rb +2 -0
- data/config/routes.rb +3 -1
- data/g5_authenticatable.gemspec +11 -7
- data/gemfiles/rails_4.1.gemfile +28 -0
- data/gemfiles/rails_4.2.gemfile +28 -0
- data/gemfiles/rails_5.0.gemfile +28 -0
- data/gemfiles/rails_5.1.gemfile +28 -0
- data/lib/g5_authenticatable.rb +3 -1
- data/lib/g5_authenticatable/engine.rb +5 -2
- data/lib/g5_authenticatable/rspec.rb +2 -0
- data/lib/g5_authenticatable/test/controller_helpers.rb +14 -9
- data/lib/g5_authenticatable/test/env_helpers.rb +3 -0
- data/lib/g5_authenticatable/test/factories/client_users.rb +45 -0
- data/lib/g5_authenticatable/test/factories/global_users.rb +43 -0
- data/lib/g5_authenticatable/test/factories/location_users.rb +45 -0
- data/lib/g5_authenticatable/test/factories/roles.rb +63 -0
- data/lib/g5_authenticatable/test/factory.rb +7 -59
- data/lib/g5_authenticatable/test/feature_helpers.rb +31 -17
- data/lib/g5_authenticatable/test/request_helpers.rb +5 -1
- data/lib/g5_authenticatable/test/token_validation_helpers.rb +15 -10
- data/lib/g5_authenticatable/version.rb +3 -1
- data/lib/generators/g5_authenticatable/install/install_generator.rb +49 -37
- data/lib/generators/g5_authenticatable/install/templates/application_policy.rb +2 -0
- data/lib/generators/g5_authenticatable/install/templates/initializer.rb +2 -0
- data/lib/generators/g5_authenticatable/install/templates/migrate/add_g5_authenticatable_users_contact_info.rb +3 -1
- data/lib/generators/g5_authenticatable/install/templates/migrate/create_g5_authenticatable_roles.rb +3 -1
- data/lib/generators/g5_authenticatable/install/templates/migrate/create_g5_authenticatable_users.rb +3 -1
- data/lib/tasks/g5_authenticatable/purge_users.rake +2 -0
- data/spec/config/application_spec.rb +7 -4
- data/spec/controllers/application_controller_spec.rb +10 -5
- data/spec/controllers/concerns/g5_authenticatable/{authorization.rb → authorization_spec.rb} +11 -6
- data/spec/dummy/app/controllers/home_controller.rb +5 -5
- data/spec/dummy/app/controllers/rails_api/secure_resources_controller.rb +6 -4
- data/spec/dummy/app/models/post.rb +1 -1
- data/spec/dummy/config/environments/test.rb +25 -4
- data/spec/dummy/config/initializers/rails_compatibility.rb +10 -0
- data/spec/dummy/db/migrate/20140206070137_create_g5_authenticatable_users.rb +3 -1
- data/spec/dummy/db/migrate/20150428182339_add_g5_authenticatable_users_contact_info.rb +3 -1
- data/spec/dummy/db/migrate/20150429212919_create_g5_authenticatable_roles.rb +2 -1
- data/spec/dummy/db/migrate/20150509061150_create_posts.rb +3 -1
- data/spec/dummy/db/migrate/20150603224032_create_g5_updatable_clients_and_locations.g5_updatable.rb +3 -1
- data/spec/dummy/db/migrate/20150603224033_create_integration_setting.g5_updatable.rb +3 -1
- data/spec/dummy/db/migrate/20150603224034_remove_integration_setting.g5_updatable.rb +3 -1
- data/spec/dummy/db/migrate/20150603224035_add_name_to_clients_and_locations.g5_updatable.rb +3 -1
- data/spec/dummy/db/migrate/20150603224036_update_names.g5_updatable.rb +3 -1
- data/spec/dummy/db/migrate/20170613201430_add_latitude_and_longitude_to_location.g5_updatable.rb +7 -0
- data/spec/dummy/db/migrate/20170613201431_copy_lat_long_props_to_lat_long_columns.g5_updatable.rb +20 -0
- data/spec/dummy/db/migrate/20170613201432_add_latitude_longitude_indexes_to_location.g5_updatable.rb +7 -0
- data/spec/dummy/db/migrate/{20161122070749_add_amenities.rb → 20170613201433_add_amenities.g5_updatable.rb} +2 -1
- data/spec/dummy/db/migrate/{20161209070749_add_client_urn_to_locations.rb → 20170613201434_add_client_urn_to_locations.g5_updatable.rb} +2 -1
- data/spec/dummy/db/migrate/20170613201435_add_points_of_interest.g5_updatable.rb +21 -0
- data/spec/dummy/db/migrate/20170613201436_add_unique_urn_indexes.g5_updatable.rb +11 -0
- data/spec/dummy/db/schema.rb +73 -61
- data/spec/factories/post.rb +2 -0
- data/spec/features/auth_error_path_spec.rb +3 -3
- data/spec/features/default_role_authorization_spec.rb +8 -4
- data/spec/features/sign_in_spec.rb +23 -13
- data/spec/features/token_validation_spec.rb +4 -2
- data/spec/g5_authenticatable/version_spec.rb +3 -1
- data/spec/lib/generators/g5_authenticatable/install_generator_spec.rb +73 -28
- data/spec/models/g5_authenticatable/role_spec.rb +8 -4
- data/spec/models/g5_authenticatable/user_spec.rb +119 -84
- data/spec/models/post_spec.rb +4 -2
- data/spec/policies/application_policy_spec.rb +80 -47
- data/spec/policies/client_policy_spec.rb +8 -5
- data/spec/policies/location_policy_spec.rb +21 -8
- data/spec/policies/selectable_client_policy_spec.rb +26 -15
- data/spec/rails_helper.rb +41 -0
- data/spec/requests/default_role_authorization_spec.rb +18 -14
- data/spec/requests/grape_api_spec.rb +7 -5
- data/spec/requests/rails_api_spec.rb +11 -9
- data/spec/requests/sign_out_spec.rb +10 -6
- data/spec/requests/token_validation_spec.rb +9 -5
- data/spec/routing/auth_error_routing_spec.rb +7 -6
- data/spec/routing/sign_out_routing_spec.rb +7 -5
- data/spec/services/g5_authenticatable/impersonate_sessionable_spec.rb +41 -18
- data/spec/spec_helper.rb +78 -45
- data/spec/support/devise.rb +3 -1
- data/spec/support/safe_request_helpers.rb +36 -0
- data/spec/support/shared_contexts/rake.rb +10 -4
- data/spec/support/shared_examples/super_admin_authorizer.rb +3 -1
- data/spec/tasks/purge_users_spec.rb +3 -1
- metadata +75 -39
- data/spec/controllers/.gitkeep +0 -0
@@ -1,19 +1,21 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'a secure Grape API' do
|
6
|
+
subject(:api_call) { safe_get '/api/secure_resource' }
|
5
7
|
|
6
8
|
context 'with an authenticated user', :auth_request do
|
7
9
|
it 'should be successful' do
|
8
10
|
api_call
|
9
|
-
expect(response).to
|
11
|
+
expect(response.status).to eq(200)
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
15
|
context 'without an authenticated user' do
|
14
16
|
it 'should be unauthorized' do
|
15
17
|
api_call
|
16
|
-
expect(response).to
|
18
|
+
expect(response.status).to eq(401)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,44 +1,46 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'a secure Rails API' do
|
4
6
|
describe 'POST request to an API-only action' do
|
5
|
-
subject(:api_call) {
|
7
|
+
subject(:api_call) { safe_post '/rails_api/secure_resource' }
|
6
8
|
|
7
9
|
context 'with an authenticated user', :auth_request do
|
8
10
|
it 'should be successful' do
|
9
11
|
api_call
|
10
|
-
expect(response).to
|
12
|
+
expect(response.status).to eq(200)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'without an authenticated user' do
|
15
17
|
it 'should be unauthorized' do
|
16
18
|
api_call
|
17
|
-
expect(response).to
|
19
|
+
expect(response.status).to eq(401)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
describe 'GET json request to mixed API/website action' do
|
23
|
-
subject(:api_call) {
|
25
|
+
subject(:api_call) { safe_get '/rails_api/secure_resource.json' }
|
24
26
|
|
25
27
|
context 'with an authenticated user', :auth_request do
|
26
28
|
it 'should be successful' do
|
27
29
|
api_call
|
28
|
-
expect(response).to
|
30
|
+
expect(response.status).to eq(200)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'without an authenticated user' do
|
33
35
|
it 'should be unauthorized' do
|
34
36
|
api_call
|
35
|
-
expect(response).to
|
37
|
+
expect(response.status).to eq(401)
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
describe 'GET html request to mixed API/website action' do
|
41
|
-
subject(:website_call) {
|
43
|
+
subject(:website_call) { safe_get '/rails_api/secure_resource.html' }
|
42
44
|
|
43
45
|
it 'should be a redirect' do
|
44
46
|
website_call
|
@@ -1,16 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
2
4
|
|
3
5
|
# Normally, we'd do this as a feature spec, but there's
|
4
6
|
# currently no easy way to get capybara to play along nicely
|
5
7
|
# with mocks for external redirects (the capybara-mechanize driver
|
6
8
|
# comes closest, but not quite)
|
7
|
-
describe 'Signing out' do
|
9
|
+
RSpec.describe 'Signing out' do
|
8
10
|
let(:auth_sign_out_url) do
|
9
|
-
"#{ENV['G5_AUTH_ENDPOINT']}/users/sign_out
|
11
|
+
"#{ENV['G5_AUTH_ENDPOINT']}/users/sign_out" \
|
12
|
+
'?redirect_url=http%3A%2F%2Fwww.example.com%2F'
|
10
13
|
end
|
11
14
|
|
12
15
|
describe 'GET /g5_auth/users/sign_out' do
|
13
|
-
subject(:sign_out) {
|
16
|
+
subject(:sign_out) { safe_get '/g5_auth/users/sign_out' }
|
14
17
|
|
15
18
|
context 'when user is logged in', :auth_request do
|
16
19
|
it 'should redirect to the auth server' do
|
@@ -19,7 +22,8 @@ describe 'Signing out' do
|
|
19
22
|
|
20
23
|
it 'should not allow the user to access protected pages' do
|
21
24
|
sign_out
|
22
|
-
expect(
|
25
|
+
expect(safe_get('/protected_page'))
|
26
|
+
.to redirect_to('/g5_auth/users/sign_in')
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
@@ -31,7 +35,7 @@ describe 'Signing out' do
|
|
31
35
|
end
|
32
36
|
|
33
37
|
describe 'DELETE /g5_auth/users/sign_out', :auth_request do
|
34
|
-
subject(:sign_out) {
|
38
|
+
subject(:sign_out) { safe_delete '/g5_auth/users/sign_out' }
|
35
39
|
|
36
40
|
it 'should redirect to GET' do
|
37
41
|
expect(sign_out).to redirect_to('/g5_auth/users/sign_out')
|
@@ -1,9 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
let(:token_info_url) { URI.join(ENV['G5_AUTH_ENDPOINT'], '/oauth/token/info') }
|
3
|
+
require 'rails_helper'
|
5
4
|
|
6
|
-
|
5
|
+
RSpec.describe 'API Token validation' do
|
6
|
+
let(:token_info_url) do
|
7
|
+
URI.join(ENV['G5_AUTH_ENDPOINT'], '/oauth/token/info')
|
8
|
+
end
|
9
|
+
|
10
|
+
subject(:api_call) { safe_get '/rails_api/secure_resource.json' }
|
7
11
|
|
8
12
|
context 'when token validation is enabled' do
|
9
13
|
before { G5Authenticatable.strict_token_validation = true }
|
@@ -36,7 +40,7 @@ describe 'API Token validation' do
|
|
36
40
|
|
37
41
|
it 'should return a 401' do
|
38
42
|
api_call
|
39
|
-
expect(response).to
|
43
|
+
expect(response.status).to eq(401)
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -1,15 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe G5Authenticatable::ErrorController do
|
6
|
+
routes { G5Authenticatable::Engine.routes }
|
5
7
|
|
6
8
|
it 'should route GET /g5_auth/auth_error path' do
|
7
|
-
expect(get: '/auth_error')
|
8
|
-
to route_to(controller: 'g5_authenticatable/error', action: 'auth_error')
|
9
|
+
expect(get: '/auth_error')
|
10
|
+
.to route_to(controller: 'g5_authenticatable/error', action: 'auth_error')
|
9
11
|
end
|
10
12
|
|
11
13
|
it 'should generate a helper' do
|
12
14
|
expect(auth_error_path).to eq('/g5_auth/auth_error')
|
13
15
|
end
|
14
|
-
|
15
16
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'Sign out routes' do
|
6
|
+
routes { G5Authenticatable::Engine.routes }
|
5
7
|
|
6
8
|
it 'should route GET /g5_auth/users/sign_out' do
|
7
|
-
expect(get('/users/sign_out'))
|
8
|
-
|
9
|
+
expect(get('/users/sign_out'))
|
10
|
+
.to route_to(controller: 'g5_authenticatable/sessions', action: 'destroy')
|
9
11
|
end
|
10
12
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe G5Authenticatable::ImpersonateSessionable do
|
4
6
|
let!(:user) { FactoryGirl.create(:g5_authenticatable_user) }
|
5
7
|
|
6
8
|
class MyImpersponateSessionableTest
|
@@ -16,31 +18,37 @@ describe G5Authenticatable::ImpersonateSessionable do
|
|
16
18
|
expect(service_instance).to receive(:impersonation_user).and_return(user)
|
17
19
|
end
|
18
20
|
|
19
|
-
it {
|
21
|
+
it { is_expected.to be_truthy }
|
20
22
|
end
|
21
23
|
|
22
24
|
describe '#impersonation_user' do
|
23
25
|
subject(:impersonation_user) { service_instance.send(:impersonation_user) }
|
24
26
|
|
25
27
|
before do
|
26
|
-
expect(service_instance).to receive(:impersonate_admin_uid)
|
28
|
+
expect(service_instance).to receive(:impersonate_admin_uid)
|
29
|
+
.and_return(user.uid)
|
27
30
|
end
|
28
31
|
|
29
|
-
it {
|
32
|
+
it { is_expected.to eq(user) }
|
30
33
|
end
|
31
34
|
|
32
35
|
describe '#user_to_impersonate' do
|
33
|
-
subject(:user_to_impersonate)
|
36
|
+
subject(:user_to_impersonate) do
|
37
|
+
service_instance.send(:user_to_impersonate)
|
38
|
+
end
|
34
39
|
|
35
40
|
before do
|
36
|
-
expect(service_instance).to receive(:impersonating_user_uid)
|
41
|
+
expect(service_instance).to receive(:impersonating_user_uid)
|
42
|
+
.and_return(user.uid)
|
37
43
|
end
|
38
44
|
|
39
|
-
it {
|
45
|
+
it { is_expected.to eq(user) }
|
40
46
|
end
|
41
47
|
|
42
48
|
describe '#able_to_impersonate?' do
|
43
|
-
subject(:able_to_impersonate)
|
49
|
+
subject(:able_to_impersonate) do
|
50
|
+
service_instance.send(:able_to_impersonate?, user, user2)
|
51
|
+
end
|
44
52
|
|
45
53
|
context 'having a super admin and any other user' do
|
46
54
|
let!(:user) do
|
@@ -50,7 +58,7 @@ describe G5Authenticatable::ImpersonateSessionable do
|
|
50
58
|
end
|
51
59
|
let!(:user2) { FactoryGirl.create(:g5_authenticatable_user) }
|
52
60
|
|
53
|
-
it {
|
61
|
+
it { is_expected.to eq(true) }
|
54
62
|
end
|
55
63
|
|
56
64
|
context 'having an admin' do
|
@@ -67,7 +75,7 @@ describe G5Authenticatable::ImpersonateSessionable do
|
|
67
75
|
user
|
68
76
|
end
|
69
77
|
|
70
|
-
it {
|
78
|
+
it { is_expected.to eq(false) }
|
71
79
|
end
|
72
80
|
|
73
81
|
context 'assuming another admin' do
|
@@ -77,22 +85,37 @@ describe G5Authenticatable::ImpersonateSessionable do
|
|
77
85
|
user
|
78
86
|
end
|
79
87
|
|
80
|
-
it {
|
88
|
+
it { is_expected.to eq(true) }
|
81
89
|
end
|
82
90
|
|
83
91
|
context 'assuming a regular user' do
|
84
92
|
let!(:user2) { FactoryGirl.create(:g5_authenticatable_user) }
|
85
93
|
|
86
|
-
it {
|
94
|
+
it { is_expected.to eq(true) }
|
87
95
|
end
|
88
96
|
end
|
89
97
|
|
90
98
|
context 'providing no user' do
|
91
|
-
|
99
|
+
context 'when user to impersonate is nil' do
|
100
|
+
let(:user) { FactoryGirl.create(:g5_authenticatable_super_admin) }
|
101
|
+
let(:user2) {}
|
102
|
+
|
103
|
+
it { is_expected.to eq(false) }
|
104
|
+
end
|
92
105
|
|
93
|
-
|
106
|
+
context 'when signed-in user is nil' do
|
107
|
+
let(:user) {}
|
108
|
+
let(:user2) { FactoryGirl.create(:g5_authenticatable_user) }
|
94
109
|
|
95
|
-
|
110
|
+
it { is_expected.to eq(false) }
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when both users are nil' do
|
114
|
+
let(:user) {}
|
115
|
+
let(:user2) {}
|
116
|
+
|
117
|
+
it { is_expected.to eq(false) }
|
118
|
+
end
|
96
119
|
end
|
97
120
|
end
|
98
121
|
|
@@ -101,12 +124,12 @@ describe G5Authenticatable::ImpersonateSessionable do
|
|
101
124
|
|
102
125
|
context 'having an existing uid' do
|
103
126
|
let(:uid) { user.uid }
|
104
|
-
it {
|
127
|
+
it { is_expected.to eq(user) }
|
105
128
|
end
|
106
129
|
|
107
130
|
context 'having a no existing uid' do
|
108
131
|
let(:uid) { 'some-random-text' }
|
109
|
-
it {
|
132
|
+
it { is_expected.to be_nil }
|
110
133
|
end
|
111
134
|
end
|
112
135
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,60 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# MUST happen before any other code is loaded
|
2
4
|
require 'simplecov'
|
3
|
-
SimpleCov.start '
|
5
|
+
SimpleCov.start 'rails'
|
6
|
+
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
4
16
|
|
5
|
-
|
6
|
-
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
7
31
|
|
8
|
-
|
9
|
-
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
10
40
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
41
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
42
|
+
# have no way to turn it off -- the option exists only for backwards
|
43
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
44
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
45
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
46
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
17
47
|
|
18
|
-
|
48
|
+
# This allows you to limit a spec run to individual examples or groups
|
49
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
50
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
51
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
52
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
53
|
+
config.filter_run_when_matching :focus
|
19
54
|
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
55
|
+
# Allows RSpec to persist some state between runs in order to support
|
56
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
57
|
+
# you configure your source control system to ignore this file.
|
58
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
23
59
|
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#
|
42
|
-
|
60
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
61
|
+
# recommended. For more details, see:
|
62
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
63
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
64
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
65
|
+
config.disable_monkey_patching!
|
66
|
+
|
67
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
68
|
+
# file, and it's useful to allow more verbose output when running an
|
69
|
+
# individual spec file.
|
70
|
+
if config.files_to_run.one?
|
71
|
+
# Use the documentation formatter for detailed output,
|
72
|
+
# unless a formatter has already been configured
|
73
|
+
# (e.g. via a command-line flag).
|
74
|
+
config.default_formatter = 'doc'
|
75
|
+
end
|
76
|
+
|
77
|
+
# Print the 10 slowest examples and example groups at the
|
78
|
+
# end of the spec run, to help surface which specs are running
|
79
|
+
# particularly slow.
|
80
|
+
# config.profile_examples = 10
|
43
81
|
|
44
82
|
# Run specs in random order to surface order dependencies. If you find an
|
45
83
|
# order dependency and want to debug it, you can fix the order by providing
|
46
84
|
# the seed, which is printed after each run.
|
47
85
|
# --seed 1234
|
48
|
-
config.order =
|
49
|
-
|
50
|
-
# These two settings work together to allow you to limit a spec run
|
51
|
-
# to individual examples or groups you care about by tagging them with
|
52
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
53
|
-
# get run.
|
54
|
-
config.filter_run :focus
|
55
|
-
config.run_all_when_everything_filtered = true
|
56
|
-
|
57
|
-
config.infer_spec_type_from_file_location!
|
86
|
+
config.order = :random
|
58
87
|
|
59
|
-
|
88
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
89
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
90
|
+
# test failures related to randomization by passing the same `--seed` value
|
91
|
+
# as the one that triggered the failure.
|
92
|
+
Kernel.srand config.seed
|
60
93
|
end
|