preconditions 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -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
@@ -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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.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-20 00:00:00 Z
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