tokenizr 1.0.2 → 1.0.3
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/tokenizr.rb +4 -0
- data/lib/tokenizr/version.rb +1 -1
- data/test/tokenizr_test.rb +16 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b263800218e29cf26e3a5626b278290a6c4c481
|
4
|
+
data.tar.gz: 5acfd3de31cfcf5ae5b5547cb0c9f628436bffff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95adfc1fe93f169bd052d341b73e7838af91d62146b62c81dbf73921347ce6c842a6e2b08f76e9e276354e977be02329a7d664443b00493fe39d72ae7cf01031
|
7
|
+
data.tar.gz: e892056c8b8dd407272955b2280a90317d6552417d3fe50a611487c23cd80c1898ef95464879493616d3047339ff2f9ce64403ef2ceeaa6cbd0ba52bc23557c6
|
data/lib/tokenizr.rb
CHANGED
data/lib/tokenizr/version.rb
CHANGED
data/test/tokenizr_test.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative '../lib/tokenizr'
|
|
2
2
|
require 'minitest/autorun'
|
3
3
|
|
4
4
|
class TokenizrTest < MiniTest::Unit::TestCase
|
5
|
-
describe '
|
5
|
+
describe '.encode' do
|
6
6
|
it 'encodes the given number into a string' do
|
7
7
|
assert_equal Tokenizr.encode(123), "5IbEL8X9e"
|
8
8
|
assert_equal Tokenizr.encode(987654321), "VGh4Q9X9e"
|
@@ -34,7 +34,7 @@ class TokenizrTest < MiniTest::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe '
|
37
|
+
describe '.decode' do
|
38
38
|
it 'decodes the given string into a number' do
|
39
39
|
assert_equal Tokenizr.decode("5IbEL8X9e"), 123
|
40
40
|
assert_equal Tokenizr.decode("VGh4Q9X9e"), 987654321
|
@@ -46,4 +46,18 @@ class TokenizrTest < MiniTest::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe '.valid_token?' do
|
51
|
+
it 'returns true for valid tokens' do
|
52
|
+
["5IbEL8X9e", "VGh4Q9X9e"].each do |token|
|
53
|
+
assert_equal Tokenizr.valid_token?(token), true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns false for invalid tokens' do
|
58
|
+
[nil, 123, 1.23, [], {}, ''].each do |token|
|
59
|
+
assert_equal Tokenizr.valid_token?(token), false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
49
63
|
end
|