rspectacular 0.44.0 → 0.45.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspectacular/plugins/authentication.rb +51 -55
- data/lib/rspectacular/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46bb75a27b3e57faa420401cfe19266d008341c
|
4
|
+
data.tar.gz: 5a183e749aefb7beda610d16f700749c520ac94d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83c157792a0da5a854e637a2541002ddd7881c2b4f12160d7f50e7c993b3d4c4effbad4174c589e71fc5e359045eccc695f1a9cdc7e622d958bb98a663b8ceab
|
7
|
+
data.tar.gz: 3c9d62b91f2177644602fa48ac6b761812baeb8d5ccea6fbb612d99a7813c3c4c8cc2563e2fd547b642cfe22867da3446dbf7fdd06b3f403023a438a0f81dd92
|
@@ -1,73 +1,69 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
2
|
config.around(:each, mock_auth: lambda { |v| !!v }) do |example|
|
3
|
-
options
|
3
|
+
options = example.metadata[:mock_auth]
|
4
4
|
|
5
|
-
klass
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
klass = case options
|
6
|
+
when TrueClass
|
7
|
+
User
|
8
|
+
when Hash
|
9
|
+
options[:class] || User
|
10
|
+
else
|
11
|
+
options
|
12
|
+
end
|
13
13
|
|
14
|
-
underscored_class_name
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
underscored_class_name = klass.
|
15
|
+
name[/(?:.*::)?(\w+)\z/, 1].
|
16
|
+
gsub(/([a-z])([A-Z])/, '\1_\2').
|
17
|
+
downcase
|
18
18
|
|
19
|
-
current_class_method
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
current_class_method = if options.is_a?(Hash) && options[:method]
|
20
|
+
options[:method]
|
21
|
+
else
|
22
|
+
:"current_#{underscored_class_name}"
|
23
|
+
end
|
24
24
|
|
25
|
-
instance
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
instance = if options.is_a?(Hash) && options[:strategy] == :instance
|
26
|
+
klass.new
|
27
|
+
else
|
28
|
+
FactoryGirl.create(underscored_class_name.to_sym)
|
29
|
+
end
|
30
30
|
|
31
|
-
inferred_auth_method
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
inferred_auth_method = if options.is_a?(Hash) && options[:authentication_method]
|
32
|
+
options[:authentication_method]
|
33
|
+
else
|
34
|
+
:"authenticate_#{underscored_class_name}!"
|
35
|
+
end
|
36
36
|
|
37
|
-
|
37
|
+
authentication_controller_class = if example.metadata[:type] == :controller
|
38
|
+
described_class
|
39
|
+
else
|
40
|
+
ApplicationController
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
inferred_auth_method
|
41
|
-
elsif described_class_instance.respond_to?(:authenticate, true)
|
42
|
-
:authenticate
|
43
|
-
end
|
43
|
+
authentication_controller_instance = authentication_controller_class.new
|
44
44
|
|
45
|
-
if
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
51
|
+
authentication_successful = if options.is_a?(Hash) && options.has_key?(:status)
|
52
|
+
options[:status] == :authorized
|
53
|
+
else
|
54
|
+
true
|
55
|
+
end
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
57
|
+
authentication_result = authentication_successful ? instance : nil
|
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 }
|
66
63
|
|
67
64
|
example.run
|
68
65
|
|
69
|
-
|
70
|
-
described_class.send(:remove_method, authentication_method)
|
66
|
+
authentication_controller_class.send(:remove_method, current_class_method)
|
71
67
|
|
72
68
|
unless options.is_a?(Hash) && options[:strategy] == :instance
|
73
69
|
instance.delete
|
data/lib/rspectacular/version.rb
CHANGED
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.
|
4
|
+
version: 0.45.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|