rspec_typeof 0.3.3 → 0.3.4
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/lib/rspec_typeof.rb +1 -1
- data/lib/rspec_typeof/typeof.rb +3 -2
- data/lib/rspec_typeof/version.rb +1 -1
- data/lib/utils/helpers.rb +9 -0
- metadata +2 -2
- data/lib/utils/string.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5a2dbf30b642e2f65f60576f661e4b532edc73
|
4
|
+
data.tar.gz: daddc3f673829d85679bb70006bd062a6f612b8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e34867bce7658a5849d606bb442fcf5ac4843ca3822c281039d24c78fa9bc4fe4c5cfef4cce5cf680b39e4f8187a5b3fdfc7d64ea40a8828403aaa0195c856
|
7
|
+
data.tar.gz: e8eac6688c91225275721705091721e983d39f52cfc9f22dfde85d1c5d6e4321c188c4f718839ed4c3f22814be84f926d5406b975b49058121011ad67cb10b50
|
data/lib/rspec_typeof.rb
CHANGED
data/lib/rspec_typeof/typeof.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "rspec"
|
2
2
|
|
3
3
|
RSpec::Matchers.define :typeof do |expected_types|
|
4
|
+
extend RspecTypeof::Helpers
|
5
|
+
|
4
6
|
matching_map = {
|
5
7
|
'nil' => 'NilClass',
|
6
8
|
'false' => 'FalseClass',
|
@@ -12,8 +14,7 @@ RSpec::Matchers.define :typeof do |expected_types|
|
|
12
14
|
.to_s
|
13
15
|
.gsub(/^array_of_/, '')
|
14
16
|
.split('_or_')
|
15
|
-
.
|
16
|
-
.map{ |v| matching_map.include?(v) ? matching_map[v] : v.camelize }
|
17
|
+
.map{ |v| matching_map.include?(v) ? matching_map[v] : camelcase(v) }
|
17
18
|
.flatten
|
18
19
|
.uniq
|
19
20
|
|
data/lib/rspec_typeof/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_typeof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vovchuk Max
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- lib/rspec_typeof.rb
|
73
73
|
- lib/rspec_typeof/typeof.rb
|
74
74
|
- lib/rspec_typeof/version.rb
|
75
|
-
- lib/utils/
|
75
|
+
- lib/utils/helpers.rb
|
76
76
|
- rspec_typeof.gemspec
|
77
77
|
homepage: https://github.com/Somiel/rspec_typeof
|
78
78
|
licenses:
|
data/lib/utils/string.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
# Defined for matching camelcase class names
|
3
|
-
def camelize(uppercase_first_letter = true)
|
4
|
-
string = self
|
5
|
-
if uppercase_first_letter
|
6
|
-
string = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
7
|
-
else
|
8
|
-
string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
|
9
|
-
end
|
10
|
-
string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
|
11
|
-
end
|
12
|
-
end
|