rspec_typeof 0.4.0 → 0.5.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/README.md +3 -2
- data/lib/rspec_typeof/typeof.rb +4 -2
- data/lib/rspec_typeof/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6720f93748c4645d8032478e17562dbb6ee76520
|
4
|
+
data.tar.gz: d4e38622673e41d4bbc30bb735da06ac28cdc1c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf94e12ece6037703a9414bf218748ccfd7738cf1c4724fdba280f3beca165acc0ff5fdc22542dfefeb4b6f94cf33a8a928126515de8e09a38e2c76d8e068534
|
7
|
+
data.tar.gz: 59d1489b57815dd821353a93c50fe3184f0961fa8df0e7cdad4726aa2519404e31f9d16e94a506313bb3a3d3d9d7495b99d697bc7e5041629bd31a1ba7da6f42
|
data/README.md
CHANGED
@@ -22,7 +22,6 @@ And then execute:
|
|
22
22
|
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
|
26
25
|
expect(true).to typeof(:true) or expect(true).to type_of(:true)
|
27
26
|
|
28
27
|
expect(true).to typeof(:string_or_nil_or_true) or expect(true).to type_of(:string_or_nil_or_true)
|
@@ -37,7 +36,9 @@ expect({string: 'string', fixnum: 2, hash: {}, array: [], custom_class: CustomCl
|
|
37
36
|
|
38
37
|
expect(['a', 'b', 'c']).to typeof(:array_of_string)
|
39
38
|
|
40
|
-
expect(['a', 'b', 1]).to typeof(:
|
39
|
+
expect(['a', 'b', 1]).to typeof(:array_of_string_or_integer)
|
40
|
+
|
41
|
+
expect(1).to typeof(:numeric)
|
41
42
|
```
|
42
43
|
|
43
44
|
## Contributing
|
data/lib/rspec_typeof/typeof.rb
CHANGED
@@ -7,7 +7,9 @@ RSpec::Matchers.define :typeof do |expected_types|
|
|
7
7
|
'nil' => 'NilClass',
|
8
8
|
'false' => 'FalseClass',
|
9
9
|
'true' => 'TrueClass',
|
10
|
-
'boolean' => ['TrueClass', 'FalseClass']
|
10
|
+
'boolean' => ['TrueClass', 'FalseClass'],
|
11
|
+
'integer' => ['Fixnum', 'Bignum'],
|
12
|
+
'numeric' => ['Fixnum', 'Bignum', 'Float', 'Rational', 'BigDecimal']
|
11
13
|
}.freeze
|
12
14
|
|
13
15
|
types = expected_types
|
@@ -22,7 +24,7 @@ RSpec::Matchers.define :typeof do |expected_types|
|
|
22
24
|
expect(actual).to satisfy do |x|
|
23
25
|
if expected_types.to_s.scan(/^array_of_\w+/).length > 0
|
24
26
|
return false unless x.is_a? Array
|
25
|
-
|
27
|
+
|
26
28
|
x.all? { |el| types.include?(el.class.name) }
|
27
29
|
else
|
28
30
|
types.include?(x.class.name)
|
data/lib/rspec_typeof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_typeof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vovchuk Max
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|