rspectacular 0.40.0 → 0.41.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 +4 -4
- data/lib/rspectacular/plugins/authentication.rb +43 -37
- data/lib/rspectacular/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 086646cb2d6416003e88309aa679fff45dc9005e
|
|
4
|
+
data.tar.gz: 41754ecd6e2932d789b1e542a081fa01c4d1672a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46040d797e8718a246b48ea05be62c108cb5f81443c7e9db0e9787760d36c2035bfd2073535497b20baf7eaba849116d5cd6fa656b185ba8ddca9d41de5fda82
|
|
7
|
+
data.tar.gz: 13e0b3dbd4c0671dd2e8acade05684a2780cefbfd4fa88ef19dba9bce2812a72751bbd9f2701cf618330e7f5eb758ae72ee08646bbc1ffe49d70040924ff3f35
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
RSpec.configure do |config|
|
|
2
|
-
config.
|
|
3
|
-
options
|
|
4
|
-
|
|
5
|
-
klass
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
underscored_class_name
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
current_class_method
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
instance
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
authentication_method
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
config.around(:each, mock_auth: lambda { |v| !!v }) do |example|
|
|
3
|
+
options = example.metadata[:mock_auth]
|
|
4
|
+
|
|
5
|
+
klass = case options
|
|
6
|
+
when TrueClass
|
|
7
|
+
User
|
|
8
|
+
when Hash
|
|
9
|
+
options[:class] || User
|
|
10
|
+
else
|
|
11
|
+
options
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
underscored_class_name = klass.
|
|
15
|
+
name[/.*::(\w+)\z/, 1].
|
|
16
|
+
gsub(/([a-z])([A-Z])/, '\1_\2').
|
|
17
|
+
downcase
|
|
18
|
+
|
|
19
|
+
current_class_method = if options.is_a?(Hash) && options[:method]
|
|
20
|
+
options[:method]
|
|
21
|
+
else
|
|
22
|
+
:"current_#{underscored_class_name}"
|
|
23
|
+
end
|
|
24
|
+
|
|
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
|
+
|
|
31
|
+
authentication_method = if options.is_a?(Hash) && options[:authentication_method]
|
|
32
|
+
options[:authentication_method]
|
|
33
|
+
else
|
|
34
|
+
:"authenticate_#{underscored_class_name}!"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
described_class_instance = described_class.new
|
|
38
|
+
|
|
39
|
+
if described_class_instance.respond_to?(authentication_method, true)
|
|
38
40
|
described_class.skip_before_action authentication_method
|
|
39
|
-
elsif
|
|
41
|
+
elsif described_class_instance.respond_to?(:authenticate, true)
|
|
40
42
|
described_class.skip_before_action :authenticate
|
|
41
43
|
end
|
|
42
44
|
|
|
@@ -45,5 +47,9 @@ RSpec.configure do |config|
|
|
|
45
47
|
described_class.send(:define_method, current_class_method) do
|
|
46
48
|
instance
|
|
47
49
|
end
|
|
50
|
+
|
|
51
|
+
example.run
|
|
52
|
+
|
|
53
|
+
described_class.send(:remove_method, current_class_method)
|
|
48
54
|
end
|
|
49
55
|
end
|
data/lib/rspectacular/version.rb
CHANGED