rspectacular 0.64.0 → 0.65.0

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
  SHA1:
3
- metadata.gz: 14d39af677d480c904f5066f93d9f21948b79608
4
- data.tar.gz: 3acef2e61df9e97668e456cd196818426bce842f
3
+ metadata.gz: 73c2c422c7bebbe4775902988a6f0300280ca137
4
+ data.tar.gz: c2075ab7b8ab3069d7c835a2c4b50ce83a3629bd
5
5
  SHA512:
6
- metadata.gz: 7537a61ce61735596027c7cc8a4e5f56db2145569ddd08ab6d03f3cb92256693ac7dd60aff73b19dc75fd49af1edfbd4d3324d8dec2835f0933ee0eaa29cafb1
7
- data.tar.gz: fd7cd53756014cbe921d4d280f0eaa62db5acaeb1f52c6b7a82d4d8c2e3bf3b8fb3220f522b128fb4556accaa65d695d35f02027d3162145d11c6abd91f63924
6
+ metadata.gz: 1ac49d89b07320ababd27d7bf50ad890e1a41546a4f5b9eee66613b5c1ac83a78408bdac4a96e4e2312fdbc14904878e4fe4266fecb9fb415f0df28f7371b96b
7
+ data.tar.gz: 1ec7adc5a672fad92f4906bb3d354ff09fda0b2bd8360189fb2e85e4122df4c589f02081ae1970b1e6fb88269aa57ae3b24dcf02e8f22cd6967257212e72f2f9
@@ -2,6 +2,12 @@ RSpec.configure do |config|
2
2
  config.around(:each, mock_auth: ->(v) { !!v }) do |example|
3
3
  options = example.metadata[:mock_auth]
4
4
 
5
+ authentication_type = if options.is_a?(Hash) && options[:type]
6
+ options[:type]
7
+ else
8
+ :standard
9
+ end
10
+
5
11
  klass = case options
6
12
  when TrueClass
7
13
  User
@@ -42,12 +48,6 @@ RSpec.configure do |config|
42
48
 
43
49
  authentication_controller_instance = authentication_controller_class.new
44
50
 
45
- authentication_method = if authentication_controller_instance.respond_to?(inferred_auth_method, true)
46
- inferred_auth_method
47
- elsif authentication_controller_instance.respond_to?(:authenticate, true)
48
- :authenticate
49
- end
50
-
51
51
  authentication_successful = if options.is_a?(Hash) && options.key?(:status)
52
52
  options[:status] == :authorized
53
53
  else
@@ -56,15 +56,54 @@ RSpec.configure do |config|
56
56
 
57
57
  authentication_result = authentication_successful ? instance : nil
58
58
 
59
- authentication_controller_class.__send__(:define_method, authentication_method) { authentication_successful }
60
- authentication_controller_class.__send__(:define_method, current_class_method) { authentication_result }
61
- authentication_controller_class.__send__(:helper_method, current_class_method)
62
- example.example_group_instance.class.let(current_class_method) { authentication_result }
59
+ if authentication_type == :standard
60
+ authentication_method = if authentication_controller_instance.respond_to?(inferred_auth_method, true)
61
+ inferred_auth_method
62
+ elsif authentication_controller_instance.respond_to?(:authenticate, true)
63
+ :authenticate
64
+ end
63
65
 
64
- example.run
66
+ authentication_controller_class.__send__(:define_method, authentication_method) { authentication_successful }
67
+ authentication_controller_class.__send__(:define_method, current_class_method) { authentication_result }
68
+ authentication_controller_class.__send__(:helper_method, current_class_method)
69
+ example.example_group_instance.class.let(current_class_method) { authentication_result }
65
70
 
66
- authentication_controller_class.__send__(:remove_method, current_class_method)
71
+ example.run
72
+
73
+ authentication_controller_class.__send__(:remove_method, current_class_method)
74
+ elsif authentication_type == :json_web_token
75
+ @token_data = if options.is_a?(Hash) && options[:data]
76
+ options[:data]
77
+ else
78
+ [
79
+ {
80
+ 'typ' => 'JWT',
81
+ 'cty' => 'application/json-web-token',
82
+ },
83
+ {
84
+ 'iss' => 'rspectacular',
85
+ 'sub' => example.file_path,
86
+ 'aud' => 'rspec',
87
+ 'exp' => 1.day.from_now.utc.to_i,
88
+ 'nbf' => 1.day.ago.utc.to_i,
89
+ 'iat' => Time.now.utc.to_i,
90
+ 'jti' => SecureRandom.uuid,
91
+ 'sid' => instance['account_id'] || instance['id'],
92
+ },
93
+ ]
94
+ end
95
+
96
+ example.example_group_instance.class.let(current_class_method) { authentication_result }
97
+
98
+ example.run
99
+ else
100
+ fail 'You must specify a valid type for the :mock_auth metadata'
101
+ end
67
102
 
68
103
  instance.delete unless options.is_a?(Hash) && options[:strategy] == :instance
69
104
  end
105
+
106
+ config.before(:each, mock_auth: ->(v) { !!v }) do |_example|
107
+ request.env['X_DECRYPTED_JSON_WEB_TOKEN'] = @token_data
108
+ end
70
109
  end
@@ -1,5 +1,6 @@
1
1
  RSpec.configure do |config|
2
2
  config.filter_run focused: true
3
3
  config.alias_example_to :fit, focused: true
4
+
4
5
  config.run_all_when_everything_filtered = true
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module Rspectacular
2
- VERSION = '0.64.0'
2
+ VERSION = '0.65.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspectacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.64.0
4
+ version: 0.65.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-11 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec