rspec-arguments 0.3.0 → 0.4.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/rspec/arguments/arguments.rb +9 -4
- data/lib/rspec/arguments/monkey_patcher.rb +15 -3
- data/lib/rspec/arguments/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: 7e76f0541e0551b3e211d1d0ff2e0e849cc04c3b
|
4
|
+
data.tar.gz: b573d640fdc5bec51d42d109d75f11a3e1af5f66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b539bf7b07af9967f1d0229397efc54f8187ed6f6ae6ebc5f583655c0ff9af0a57fab3467c26025aedac23be42ad43e830528e6df40d35b19234c314a3cdaa0c
|
7
|
+
data.tar.gz: c51b4a98b404a13b55ef59da1844faac6356a64561bc277f02e798bf068c762dfabdda7f27900c3f938b7855719546fbb88d1e5e4ab8fc3ae5f347c2ba23f63d
|
@@ -15,17 +15,22 @@ module RSpec
|
|
15
15
|
METHOD_KEYWORD_ARG = METHOD_ARG_PREFIX + KEYWORD_ARG_SUFFIX
|
16
16
|
METHOD_BLOCK_ARG = METHOD_ARG_PREFIX + BLOCK_ARG_SUFFIX
|
17
17
|
|
18
|
-
def process_subject(clazz
|
18
|
+
def process_subject(clazz)
|
19
19
|
class_method = method_under_test(:class_method)
|
20
20
|
|
21
21
|
return call_method_with_args(clazz, class_method.to_sym) if class_method
|
22
22
|
|
23
|
-
process_instance_subject(clazz
|
23
|
+
process_instance_subject(clazz)
|
24
|
+
end
|
25
|
+
|
26
|
+
def process_instance(clazz)
|
27
|
+
__memoized.fetch_or_store(:instance) do
|
28
|
+
call_initializer_with_args(clazz)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
|
26
32
|
def process_instance_subject(clazz)
|
27
|
-
instance =
|
28
|
-
yield(instance)
|
33
|
+
instance = process_instance(clazz)
|
29
34
|
|
30
35
|
method = method_under_test(:method)
|
31
36
|
|
@@ -17,7 +17,7 @@ module RSpec
|
|
17
17
|
|
18
18
|
if described.is_a?(Class)
|
19
19
|
if metadata[:rspec_arguments] || metadata[:method] || metadata[:class_method]
|
20
|
-
process_subject(described)
|
20
|
+
process_subject(described)
|
21
21
|
else
|
22
22
|
described.new
|
23
23
|
end
|
@@ -31,8 +31,20 @@ module RSpec
|
|
31
31
|
# Reference to the instantiated object, if testing an instance or instance method (but not class method).
|
32
32
|
#
|
33
33
|
def instance
|
34
|
-
|
35
|
-
|
34
|
+
__memoized.fetch_or_store(:instance) do
|
35
|
+
metadata = self.class.metadata
|
36
|
+
described = described_class || metadata.fetch(:description_args).first
|
37
|
+
|
38
|
+
if described.is_a?(Class)
|
39
|
+
if metadata[:rspec_arguments] || metadata[:method] || metadata[:class_method]
|
40
|
+
raise 'Instance is only available when testing class instances or instance methods' if metadata[:class_method]
|
41
|
+
|
42
|
+
process_instance(described)
|
43
|
+
else
|
44
|
+
described.new
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
36
48
|
end
|
37
49
|
end
|
38
50
|
end
|