rspectacular 0.39.0 → 0.40.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: 14ef6df491a7c1e7219877852aade08075fd4d84
4
- data.tar.gz: 2c9ae504062ccd239761ef0108f938e1f9440940
3
+ metadata.gz: c4514a7c374f578a05e5068349aed748650e092e
4
+ data.tar.gz: 1b7d278797738f516ecd769a6004943d968426ff
5
5
  SHA512:
6
- metadata.gz: f7b0e379303ea7ba08fbcaaecfd323dde28a598b7cd028e6f1b0ad62c9f69e300d9b59611b5d80521870b6c263254779f59b56274e3663aa8b3a06fcc81399a3
7
- data.tar.gz: 8813454b4a06b59f024afc2736b254a102d4b1b350a4478b531482fb270739e0f4fd4a8de1cd4727b6ca8e4739205933a3278d564b94a233403052cf593c6836
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
@@ -1,3 +1,3 @@
1
1
  module RSpectacular
2
- VERSION = '0.39.0'
2
+ VERSION = '0.40.0'
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.39.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-08 00:00:00.000000000 Z
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: