preconditions 0.1.1 → 0.1.2
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.
- data/VERSION +1 -1
- data/lib/preconditions.rb +1 -1
- data/spec/preconditions_spec.rb +4 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/preconditions.rb
CHANGED
@@ -51,7 +51,7 @@ module Preconditions
|
|
51
51
|
# @return obj
|
52
52
|
# @raise [TypeError] if obj is not an instance of expected_type
|
53
53
|
def check_type(obj, expected_type, msg=nil, *fmt)
|
54
|
-
if !obj.kind_of?(expected_type)
|
54
|
+
if !obj.nil? && !obj.kind_of?(expected_type)
|
55
55
|
raise_exception(TypeError, msg, *fmt)
|
56
56
|
end
|
57
57
|
obj
|
data/spec/preconditions_spec.rb
CHANGED
@@ -59,6 +59,10 @@ end
|
|
59
59
|
subject.check_type(1, Integer).should == 1
|
60
60
|
end
|
61
61
|
|
62
|
+
it "returns the argument in a type check when the type is nil" do
|
63
|
+
subject.check_type(nil, Integer).should == nil
|
64
|
+
end
|
65
|
+
|
62
66
|
it "raises a NameError when argument does not support requested method" do
|
63
67
|
expect { subject.check_responds_to(1, :no_such_method) }.
|
64
68
|
to raise_exception
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: preconditions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- tucker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-22 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|