quacky 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/quacky/duck_type_verifier.rb +12 -10
- data/spec/lib/duck_type_verifier_spec.rb +18 -0
- metadata +12 -12
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.8
|
@@ -10,16 +10,18 @@ module Quacky
|
|
10
10
|
duck_type_methods.each do |method|
|
11
11
|
raise Quacky::DuckTypeVerificationFailure, "object does not respond to `#{method.name}'" unless object.respond_to?(method.name)
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
begin
|
14
|
+
target_method = object.public_method(method.name)
|
15
|
+
return true if target_method.parameters.any? { |p| p.first == :rest }
|
16
|
+
|
17
|
+
method_parameters = method.parameters.reject { |p| p.first == :block }
|
18
|
+
target_method_parameters = target_method.parameters.reject { |p| p.first == :block }
|
19
|
+
|
20
|
+
if target_method_parameters.count != method_parameters.count ||
|
21
|
+
target_method_parameters.map {|p| p.first } != method_parameters.map {|p| p.first}
|
22
|
+
raise Quacky::DuckTypeVerificationFailure, "definitions of method `#{method.name}` differ in parameters accepted."
|
23
|
+
end
|
24
|
+
rescue NameError; end
|
23
25
|
|
24
26
|
true
|
25
27
|
end
|
@@ -75,5 +75,23 @@ describe Quacky::DuckTypeVerifier do
|
|
75
75
|
expect { verifier.verify! conforming_object }.not_to raise_exception Quacky::DuckTypeVerificationFailure
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
context "given an object that responds to but does not explicitly implement a method" do
|
80
|
+
let(:unexplicitly_conforming_object) do
|
81
|
+
Class.new do
|
82
|
+
def respond_to?(method_name, include_private = false)
|
83
|
+
method_name.to_s == 'quack' || super
|
84
|
+
end
|
85
|
+
end.new
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not raise a DuckTypeVerificationError" do
|
89
|
+
expect { verifier.verify! conforming_object }.not_to raise_exception Quacky::DuckTypeVerificationFailure
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not raise a NameError" do
|
93
|
+
expect { verifier.verify! conforming_object }.not_to raise_exception NameError
|
94
|
+
end
|
95
|
+
end
|
78
96
|
end
|
79
97
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quacky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70163961734680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70163961734680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70163961732480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70163961732480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: cucumber
|
38
|
-
requirement: &
|
38
|
+
requirement: &70163961758520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70163961758520
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: specdown
|
49
|
-
requirement: &
|
49
|
+
requirement: &70163961757240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70163961757240
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70163961756140 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70163961756140
|
69
69
|
description:
|
70
70
|
email: moonmaster9000@gmail.com
|
71
71
|
executables: []
|