rspectacular 0.39.0 → 0.40.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 +49 -0
- data/lib/rspectacular/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4514a7c374f578a05e5068349aed748650e092e
|
4
|
+
data.tar.gz: 1b7d278797738f516ecd769a6004943d968426ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58da3af6fb889c8660d551b2d8e95f01df2d8e3df9e3613b88cb44696fac2fdcc193d331fe7da1efedc628f3efbb3eb1aa559f485d175539488e2dc6b431aea6
|
7
|
+
data.tar.gz: b9278de9218dc98a0092dec84f32511e60979316d34856f54dbf7f3c0c78e935f445651eda5a448935ee117018488bb593d7215e1d66c374a94b028ccb7616fd
|
@@ -0,0 +1,49 @@
|
|
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)
|
38
|
+
described_class.skip_before_action authentication_method
|
39
|
+
elsif subject.respond_to?(:authenticate, true)
|
40
|
+
described_class.skip_before_action :authenticate
|
41
|
+
end
|
42
|
+
|
43
|
+
example.example_group_instance.class.let(current_class_method) { instance }
|
44
|
+
|
45
|
+
described_class.send(:define_method, current_class_method) do
|
46
|
+
instance
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
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.40.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/rspectacular/mock_authentications/omniauth/facebook.rb
|
74
74
|
- lib/rspectacular/mock_authentications/omniauth/twitter.rb
|
75
75
|
- lib/rspectacular/plugins.rb
|
76
|
+
- lib/rspectacular/plugins/authentication.rb
|
76
77
|
- lib/rspectacular/plugins/bullet.rb
|
77
78
|
- lib/rspectacular/plugins/capybara.rb
|
78
79
|
- lib/rspectacular/plugins/carrier_wave.rb
|
@@ -140,3 +141,4 @@ specification_version: 4
|
|
140
141
|
summary: RSpec Support And Matchers
|
141
142
|
test_files:
|
142
143
|
- spec/spec_helper.rb
|
144
|
+
has_rdoc:
|