assert_type 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/assert_type/type_validator.rb +3 -1
- data/lib/assert_type/version.rb +1 -1
- data/spec/assert_type_spec.rb +8 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/type_validator_spec.rb +19 -0
- metadata +22 -44
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2db5929824a8014f891a1619c7105c9589352a25
|
4
|
+
data.tar.gz: a98f304cc29eb614b1392bef59a032cdcd6ef692
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb02c29cb86208c3e84f40d07b294d09adcd3e92f487ca1e18a7a5cf152ada22929a78721d58a820b25e5812fa4297dc4e00738d9bd96c30299c89394b03e82a
|
7
|
+
data.tar.gz: d524bfb482e82294985980213a034ab04d5cef808996468bc88072a1f4a9418614c88a91371b6205a6effdcc774356d0b8ebfa6fe2e941bb43a4fcab9dc8b50e
|
data/lib/assert_type/version.rb
CHANGED
data/spec/assert_type_spec.rb
CHANGED
@@ -45,6 +45,14 @@ describe AssertType do
|
|
45
45
|
example_valid "String, Symbol", :Symbol
|
46
46
|
example_invalid "String, Symbol", 42
|
47
47
|
|
48
|
+
example_valid "AssertType::TestClass", AssertType::TestClass.new
|
49
|
+
example_invalid "AssertType::TestClass", AssertType::TestClass
|
50
|
+
example_valid "AssertType::TestClass", AssertType::TestSubClass.new
|
51
|
+
|
52
|
+
example_invalid "Array<AssertType::TestSubClass>", [AssertType::TestClass.new]
|
53
|
+
example_valid "Array<AssertType::TestSubClass>", [AssertType::TestSubClass.new]
|
54
|
+
example_valid "Array<AssertType::TestSubClass>", [AssertType::TestSubSubClass.new]
|
55
|
+
|
48
56
|
example_call_error Array, []
|
49
57
|
example_call_error [Fixnum, String], 1
|
50
58
|
example_call_error [1,2,3], "Array<Fixnum>"
|
data/spec/spec_helper.rb
CHANGED
@@ -5,3 +5,7 @@ require File.expand_path("../lib/assert_type.rb", File.dirname(__FILE__))
|
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
7
|
end
|
8
|
+
|
9
|
+
class AssertType::TestClass; end
|
10
|
+
class AssertType::TestSubClass < AssertType::TestClass; end
|
11
|
+
class AssertType::TestSubSubClass < AssertType::TestSubClass; end
|
data/spec/type_validator_spec.rb
CHANGED
@@ -109,6 +109,25 @@ module AssertType
|
|
109
109
|
TypeValidator.valid?(node, false).should be_false
|
110
110
|
end
|
111
111
|
|
112
|
+
it "example: custom class" do
|
113
|
+
node = stub("TypeNode", :name => "_root", :children => [
|
114
|
+
stub("TypeNode", :name => "AssertType::TestClass", :children => [])
|
115
|
+
])
|
116
|
+
TypeValidator.valid?(node, {}).should be_false
|
117
|
+
TypeValidator.valid?(node, []).should be_false
|
118
|
+
TypeValidator.valid?(node, AssertType::TestClass).should be_false
|
119
|
+
TypeValidator.valid?(node, AssertType::TestClass.new).should be_true
|
120
|
+
end
|
121
|
+
|
122
|
+
it "example: subclass" do
|
123
|
+
node = stub("TypeNode", :name => "_root", :children => [
|
124
|
+
stub("TypeNode", :name => "AssertType::TestSubClass", :children => [])
|
125
|
+
])
|
126
|
+
TypeValidator.valid?(node, AssertType::TestClass.new).should be_false
|
127
|
+
TypeValidator.valid?(node, AssertType::TestSubClass.new).should be_true
|
128
|
+
TypeValidator.valid?(node, AssertType::TestSubSubClass.new).should be_true
|
129
|
+
end
|
130
|
+
|
112
131
|
## Note: we can't parse this yet
|
113
132
|
#xit "example: Hash{Symbol => Fixnum}" do
|
114
133
|
# node = stub("TypeNode", :name => "Hash", :children => [
|
metadata
CHANGED
@@ -1,33 +1,22 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert_type
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Joel Plane
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2013-07-01 00:00:00 Z
|
11
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
19
12
|
dependencies: []
|
20
|
-
|
21
13
|
description: A method for very basic nested type assertions
|
22
|
-
email:
|
14
|
+
email:
|
23
15
|
- joel.plane@gmail.com
|
24
16
|
executables: []
|
25
|
-
|
26
17
|
extensions: []
|
27
|
-
|
28
18
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
19
|
+
files:
|
31
20
|
- .gitignore
|
32
21
|
- Gemfile
|
33
22
|
- README.md
|
@@ -49,38 +38,27 @@ files:
|
|
49
38
|
- spec/type_string_parser_spec.rb
|
50
39
|
- spec/type_string_tokeniser_spec.rb
|
51
40
|
- spec/type_validator_spec.rb
|
52
|
-
homepage:
|
41
|
+
homepage: ''
|
53
42
|
licenses: []
|
54
|
-
|
43
|
+
metadata: {}
|
55
44
|
post_install_message:
|
56
45
|
rdoc_options: []
|
57
|
-
|
58
|
-
require_paths:
|
46
|
+
require_paths:
|
59
47
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
none: false
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
78
58
|
requirements: []
|
79
|
-
|
80
59
|
rubyforge_project:
|
81
|
-
rubygems_version:
|
60
|
+
rubygems_version: 2.0.3
|
82
61
|
signing_key:
|
83
|
-
specification_version:
|
62
|
+
specification_version: 4
|
84
63
|
summary: simple method to do type assertions
|
85
64
|
test_files: []
|
86
|
-
|