rspectacular 0.40.0 → 0.41.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4514a7c374f578a05e5068349aed748650e092e
4
- data.tar.gz: 1b7d278797738f516ecd769a6004943d968426ff
3
+ metadata.gz: 086646cb2d6416003e88309aa679fff45dc9005e
4
+ data.tar.gz: 41754ecd6e2932d789b1e542a081fa01c4d1672a
5
5
  SHA512:
6
- metadata.gz: 58da3af6fb889c8660d551b2d8e95f01df2d8e3df9e3613b88cb44696fac2fdcc193d331fe7da1efedc628f3efbb3eb1aa559f485d175539488e2dc6b431aea6
7
- data.tar.gz: b9278de9218dc98a0092dec84f32511e60979316d34856f54dbf7f3c0c78e935f445651eda5a448935ee117018488bb593d7215e1d66c374a94b028ccb7616fd
6
+ metadata.gz: 46040d797e8718a246b48ea05be62c108cb5f81443c7e9db0e9787760d36c2035bfd2073535497b20baf7eaba849116d5cd6fa656b185ba8ddca9d41de5fda82
7
+ data.tar.gz: 13e0b3dbd4c0671dd2e8acade05684a2780cefbfd4fa88ef19dba9bce2812a72751bbd9f2701cf618330e7f5eb758ae72ee08646bbc1ffe49d70040924ff3f35
@@ -1,42 +1,44 @@
1
1
  RSpec.configure do |config|
2
- config.before(: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
- if subject.respond_to?(authentication_method, true)
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 subject.respond_to?(:authenticate, true)
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
@@ -1,3 +1,3 @@
1
1
  module RSpectacular
2
- VERSION = '0.40.0'
2
+ VERSION = '0.41.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspectacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.0
4
+ version: 0.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfelchner