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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e92f0934e150361b30051d9e34e8d780e8f987fb
4
- data.tar.gz: 98677e3ea77e66f4ba10ef45826b65e3bd51850b
3
+ metadata.gz: 7d5a2dbf30b642e2f65f60576f661e4b532edc73
4
+ data.tar.gz: daddc3f673829d85679bb70006bd062a6f612b8f
5
5
  SHA512:
6
- metadata.gz: f193db7ecf771bc39294245aa4ccb2f8580aa7817cd0af6ba656650eda90bdc4aac5cbe4e6bb4693901ce6a2e5af2f563652c6e45639d7079540c1df917fd6dd
7
- data.tar.gz: 4c79877b5749d634e0d6b0927490451b91108bafef007671826c1e0d9ac464da154368b290df44956fab1c53ea4dee674f4ce2d61f248c32a3bd8f3c3ed3cb53
6
+ metadata.gz: a2e34867bce7658a5849d606bb442fcf5ac4843ca3822c281039d24c78fa9bc4fe4c5cfef4cce5cf680b39e4f8187a5b3fdfc7d64ea40a8828403aaa0195c856
7
+ data.tar.gz: e8eac6688c91225275721705091721e983d39f52cfc9f22dfde85d1c5d6e4321c188c4f718839ed4c3f22814be84f926d5406b975b49058121011ad67cb10b50
data/lib/rspec_typeof.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "rspec_typeof/version"
2
2
  require "rspec_typeof/typeof"
3
- require "utils/string"
3
+ require "utils/helpers"
4
4
 
5
5
  module RspecTypeof
6
6
  end
@@ -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
- .uniq
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
 
@@ -1,3 +1,3 @@
1
1
  module RspecTypeof
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
@@ -0,0 +1,9 @@
1
+ module RspecTypeof
2
+ module Helpers
3
+ # Defined for matching camelcase class names
4
+ def camelcase(string)
5
+ string = string.sub(/^[a-z\d]*/) { $&.capitalize }
6
+ string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
7
+ end
8
+ end
9
+ end
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.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/string.rb
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