string_foundation 1.0.0 → 1.1.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/CHANGELOG.md +5 -0
- data/Gemfile +9 -9
- data/Gemfile.lock +19 -19
- data/{LICENSE.txt → LICENSE} +1 -1
- data/PULL_REQUEST_TEMPLATE.md +14 -0
- data/README.md +244 -104
- data/Rakefile +3 -3
- data/bin/console +1 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/application.css +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/application.js +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/border.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/controls.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/loading.gif +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/loading_background.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/favicon_green.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/favicon_red.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/favicon_yellow.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/loading.gif +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/magnify.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +5885 -3160
- data/lib/string_foundation.rb +4 -2
- data/lib/string_foundation/blank.rb +17 -0
- data/lib/string_foundation/case.rb +28 -38
- data/lib/string_foundation/convert.rb +9 -9
- data/lib/string_foundation/convertible.rb +4 -4
- data/lib/string_foundation/is.rb +13 -0
- data/lib/string_foundation/length.rb +56 -0
- data/lib/string_foundation/like.rb +4 -4
- data/lib/string_foundation/version.rb +2 -2
- data/lib/string_foundation/with.rb +7 -7
- data/pkg/string_foundation-1.1.0.gem +0 -0
- data/spec/spec_helper.rb +10 -10
- data/spec/string_foundation/blank_spec.rb +91 -0
- data/spec/string_foundation/case_spec.rb +398 -433
- data/spec/string_foundation/convert_spec.rb +98 -98
- data/spec/string_foundation/convertible_spec.rb +286 -0
- data/spec/string_foundation/is_spec.rb +62 -0
- data/spec/string_foundation/length_spec.rb +226 -0
- data/spec/string_foundation/like_spec.rb +103 -103
- data/spec/string_foundation/version_spec.rb +4 -4
- data/spec/string_foundation/with_spec.rb +48 -48
- data/spec/support/enhanced_matchers_extension.rb +1 -0
- data/string_foundation.gemspec +15 -14
- metadata +46 -37
- data/circle.yml +0 -14
- data/pkg/string_foundation-1.0.0.gem +0 -0
- data/spec/string_foundation/convertaile_spec.rb +0 -286
@@ -1,14 +1,14 @@
|
|
1
1
|
# ==============================================================================
|
2
|
-
# SPEC - STRING FOUNDATION - VERSION
|
3
|
-
# ==============================================================================
|
2
|
+
# SPEC - STRING FOUNDATION - VERSION SPEC
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
describe StringFoundation::VERSION do
|
6
6
|
|
7
7
|
# ----------------------------------------------------------------------------
|
8
8
|
# Version Definition
|
9
9
|
# ----------------------------------------------------------------------------
|
10
|
-
it
|
11
|
-
expect(StringFoundation::VERSION).not_to
|
10
|
+
it "should have a version number" do
|
11
|
+
expect(StringFoundation::VERSION).not_to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -1,97 +1,97 @@
|
|
1
1
|
# ==============================================================================
|
2
|
-
# SPEC - STRING FOUNDATION -
|
3
|
-
# ==============================================================================
|
2
|
+
# SPEC - STRING FOUNDATION - WITH SPEC
|
4
3
|
# frozen_string_literal: true
|
5
|
-
|
4
|
+
# ==============================================================================
|
5
|
+
describe "[ With Methods ]" do
|
6
6
|
|
7
7
|
# ----------------------------------------------------------------------------
|
8
8
|
# Without Leading Zeros
|
9
9
|
# ----------------------------------------------------------------------------
|
10
|
-
describe
|
10
|
+
describe "WITHOUT LEADING ZEROS ::" do
|
11
11
|
let(:string_number) { nil }
|
12
12
|
subject { string_number.without_leading_zeros }
|
13
13
|
|
14
|
-
context
|
15
|
-
context
|
16
|
-
let(:string_number) {
|
14
|
+
context "when a string has leading zeros," do
|
15
|
+
context "without a plus or minus sign," do
|
16
|
+
let(:string_number) { "0000123" }
|
17
17
|
|
18
|
-
it { is_expected.to eq
|
18
|
+
it { is_expected.to eq("123") }
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
22
|
-
let(:string_number) {
|
21
|
+
context "with a minus sign," do
|
22
|
+
let(:string_number) { "-0000123" }
|
23
23
|
|
24
|
-
it { is_expected.to eq
|
24
|
+
it { is_expected.to eq("-123") }
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context
|
29
|
-
context
|
30
|
-
let(:string_number) {
|
28
|
+
context "when a string has some zero characters," do
|
29
|
+
context "without a plus or minus sign," do
|
30
|
+
let(:string_number) { "00001230000" }
|
31
31
|
|
32
|
-
it { is_expected.to eq
|
32
|
+
it { is_expected.to eq("1230000") }
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
-
context
|
37
|
-
let(:string_number) {
|
36
|
+
context "with a minus sign," do
|
37
|
+
let(:string_number) { "-00001230000" }
|
38
38
|
|
39
|
-
it { is_expected.to eq
|
39
|
+
it { is_expected.to eq("-1230000") }
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
context
|
44
|
-
context
|
45
|
-
let(:string_number) {
|
43
|
+
context "when a string like a floating point number has leading zeros," do
|
44
|
+
context "without a plus or minus sign," do
|
45
|
+
let(:string_number) { "000000.3" }
|
46
46
|
|
47
|
-
it { is_expected.to eq
|
47
|
+
it { is_expected.to eq("0.3") }
|
48
48
|
end
|
49
49
|
|
50
|
-
context
|
51
|
-
let(:string_number) {
|
50
|
+
context "with a minus sign," do
|
51
|
+
let(:string_number) { "-000000.3" }
|
52
52
|
|
53
|
-
it { is_expected.to eq
|
53
|
+
it { is_expected.to eq("-0.3") }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
context
|
58
|
-
context
|
59
|
-
let(:string_number) {
|
57
|
+
context "when a string is \"0\"," do
|
58
|
+
context "without a plus or minus sign," do
|
59
|
+
let(:string_number) { "0" }
|
60
60
|
|
61
|
-
it { is_expected.to eq
|
61
|
+
it { is_expected.to eq("0") }
|
62
62
|
end
|
63
63
|
|
64
|
-
context
|
65
|
-
let(:string_number) {
|
64
|
+
context "with a minus sign," do
|
65
|
+
let(:string_number) { "-0" }
|
66
66
|
|
67
|
-
it { is_expected.to eq
|
67
|
+
it { is_expected.to eq("0") }
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
context
|
72
|
-
context
|
73
|
-
it
|
74
|
-
expect(
|
75
|
-
expect(
|
76
|
-
expect(
|
77
|
-
expect(
|
71
|
+
context "when a string has only zero characters," do
|
72
|
+
context "without a plus or minus sign," do
|
73
|
+
it "should return a string \"0\"" do
|
74
|
+
expect("00".without_leading_zeros).to eq("0")
|
75
|
+
expect("000".without_leading_zeros).to eq("0")
|
76
|
+
expect("0000".without_leading_zeros).to eq("0")
|
77
|
+
expect("00000".without_leading_zeros).to eq("0")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
context
|
82
|
-
it
|
83
|
-
expect(
|
84
|
-
expect(
|
85
|
-
expect(
|
86
|
-
expect(
|
81
|
+
context "with a minus sign," do
|
82
|
+
it "should return a string \"0\"" do
|
83
|
+
expect("-00".without_leading_zeros).to eq("0")
|
84
|
+
expect("-000".without_leading_zeros).to eq("0")
|
85
|
+
expect("-0000".without_leading_zeros).to eq("0")
|
86
|
+
expect("-00000".without_leading_zeros).to eq("0")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
context
|
92
|
-
it
|
91
|
+
context "when a string does not start with \"0\" and \"-0\"," do
|
92
|
+
it "should return the same string" do
|
93
93
|
random_text = RandomToken.gen(10, seed: :alphabet).without_leading_zeros
|
94
|
-
expect(random_text).to eq
|
94
|
+
expect(random_text).to eq(random_text)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# SPEC - SUPPORT - ENHANCED MATCHERS EXTENSION
|
3
|
+
# frozen_string_literal: true
|
3
4
|
# ==============================================================================
|
4
5
|
module EnhancedMatchersExtension
|
5
6
|
|
data/string_foundation.gemspec
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# STRING FOUNDATION GEMSPEC
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
$:.push File.expand_path("../lib", __FILE__)
|
6
|
-
require
|
6
|
+
require "string_foundation/version"
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
|
-
spec.name
|
10
|
-
spec.version
|
11
|
-
spec.platform
|
12
|
-
spec.authors
|
13
|
-
spec.email
|
14
|
-
spec.homepage
|
15
|
-
spec.summary
|
16
|
-
spec.description
|
17
|
-
spec.
|
9
|
+
spec.name = "string_foundation"
|
10
|
+
spec.version = StringFoundation::VERSION
|
11
|
+
spec.platform = Gem::Platform::RUBY
|
12
|
+
spec.authors = ["Jaga Apple"]
|
13
|
+
spec.email = ["jagaapple@uniboar.com"]
|
14
|
+
spec.homepage = "https://github.com/jagaapple/string_foundation.rb"
|
15
|
+
spec.summary = "A library that extends Ruby string class."
|
16
|
+
spec.description = "String Foundation is a Ruby library that provides useful methods for the Ruby string class."
|
17
|
+
spec.required_ruby_version = ">= 2.1.0"
|
18
|
+
spec.license = "MIT"
|
18
19
|
|
19
|
-
spec.files = Dir[
|
20
|
-
spec.test_files = Dir[
|
21
|
-
spec.require_paths = [
|
20
|
+
spec.files = Dir["**/*"].keep_if { |file| File.file?(file) }
|
21
|
+
spec.test_files = Dir["spec/**/*"]
|
22
|
+
spec.require_paths = ["lib"]
|
22
23
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string_foundation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Jaga Apple
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: String Foundation is a Ruby library that provides useful methods for
|
14
14
|
the Ruby string class.
|
15
15
|
email:
|
16
|
-
-
|
16
|
+
- jagaapple@uniboar.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
@@ -22,56 +22,62 @@ files:
|
|
22
22
|
- CODE_OF_CONDUCT.md
|
23
23
|
- Gemfile
|
24
24
|
- Gemfile.lock
|
25
|
-
- LICENSE
|
25
|
+
- LICENSE
|
26
|
+
- PULL_REQUEST_TEMPLATE.md
|
26
27
|
- README.md
|
27
28
|
- Rakefile
|
28
29
|
- bin/console
|
29
30
|
- bin/setup
|
30
|
-
-
|
31
|
-
- coverage/assets/0.10.
|
32
|
-
- coverage/assets/0.10.
|
33
|
-
- coverage/assets/0.10.
|
34
|
-
- coverage/assets/0.10.
|
35
|
-
- coverage/assets/0.10.
|
36
|
-
- coverage/assets/0.10.
|
37
|
-
- coverage/assets/0.10.
|
38
|
-
- coverage/assets/0.10.
|
39
|
-
- coverage/assets/0.10.
|
40
|
-
- coverage/assets/0.10.
|
41
|
-
- coverage/assets/0.10.
|
42
|
-
- coverage/assets/0.10.
|
43
|
-
- coverage/assets/0.10.
|
44
|
-
- coverage/assets/0.10.
|
45
|
-
- coverage/assets/0.10.
|
46
|
-
- coverage/assets/0.10.
|
47
|
-
- coverage/assets/0.10.
|
48
|
-
- coverage/assets/0.10.
|
49
|
-
- coverage/assets/0.10.
|
50
|
-
- coverage/assets/0.10.
|
51
|
-
- coverage/assets/0.10.
|
52
|
-
- coverage/assets/0.10.
|
53
|
-
- coverage/assets/0.10.
|
54
|
-
- coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png
|
31
|
+
- coverage/assets/0.10.2/application.css
|
32
|
+
- coverage/assets/0.10.2/application.js
|
33
|
+
- coverage/assets/0.10.2/colorbox/border.png
|
34
|
+
- coverage/assets/0.10.2/colorbox/controls.png
|
35
|
+
- coverage/assets/0.10.2/colorbox/loading.gif
|
36
|
+
- coverage/assets/0.10.2/colorbox/loading_background.png
|
37
|
+
- coverage/assets/0.10.2/favicon_green.png
|
38
|
+
- coverage/assets/0.10.2/favicon_red.png
|
39
|
+
- coverage/assets/0.10.2/favicon_yellow.png
|
40
|
+
- coverage/assets/0.10.2/loading.gif
|
41
|
+
- coverage/assets/0.10.2/magnify.png
|
42
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
43
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
44
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
45
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
46
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
47
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
48
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
49
|
+
- coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
50
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png
|
51
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png
|
52
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png
|
53
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png
|
54
|
+
- coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png
|
55
55
|
- coverage/index.html
|
56
56
|
- lib/string_foundation.rb
|
57
|
+
- lib/string_foundation/blank.rb
|
57
58
|
- lib/string_foundation/case.rb
|
58
59
|
- lib/string_foundation/convert.rb
|
59
60
|
- lib/string_foundation/convertible.rb
|
61
|
+
- lib/string_foundation/is.rb
|
62
|
+
- lib/string_foundation/length.rb
|
60
63
|
- lib/string_foundation/like.rb
|
61
64
|
- lib/string_foundation/version.rb
|
62
65
|
- lib/string_foundation/with.rb
|
63
|
-
- pkg/string_foundation-1.
|
66
|
+
- pkg/string_foundation-1.1.0.gem
|
64
67
|
- spec/spec_helper.rb
|
68
|
+
- spec/string_foundation/blank_spec.rb
|
65
69
|
- spec/string_foundation/case_spec.rb
|
66
70
|
- spec/string_foundation/convert_spec.rb
|
67
|
-
- spec/string_foundation/
|
71
|
+
- spec/string_foundation/convertible_spec.rb
|
72
|
+
- spec/string_foundation/is_spec.rb
|
73
|
+
- spec/string_foundation/length_spec.rb
|
68
74
|
- spec/string_foundation/like_spec.rb
|
69
75
|
- spec/string_foundation/version_spec.rb
|
70
76
|
- spec/string_foundation/with_spec.rb
|
71
77
|
- spec/support/enhanced_matchers_extension.rb
|
72
78
|
- string_foundation.gemspec
|
73
79
|
- string_foundation.png
|
74
|
-
homepage: https://github.com/
|
80
|
+
homepage: https://github.com/jagaapple/string_foundation.rb
|
75
81
|
licenses:
|
76
82
|
- MIT
|
77
83
|
metadata: {}
|
@@ -83,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
89
|
requirements:
|
84
90
|
- - ">="
|
85
91
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
92
|
+
version: 2.1.0
|
87
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
94
|
requirements:
|
89
95
|
- - ">="
|
@@ -97,10 +103,13 @@ specification_version: 4
|
|
97
103
|
summary: A library that extends Ruby string class.
|
98
104
|
test_files:
|
99
105
|
- spec/spec_helper.rb
|
100
|
-
- spec/string_foundation/case_spec.rb
|
101
106
|
- spec/string_foundation/convert_spec.rb
|
102
|
-
- spec/string_foundation/
|
103
|
-
- spec/string_foundation/
|
107
|
+
- spec/string_foundation/is_spec.rb
|
108
|
+
- spec/string_foundation/blank_spec.rb
|
104
109
|
- spec/string_foundation/version_spec.rb
|
110
|
+
- spec/string_foundation/case_spec.rb
|
105
111
|
- spec/string_foundation/with_spec.rb
|
112
|
+
- spec/string_foundation/convertible_spec.rb
|
113
|
+
- spec/string_foundation/length_spec.rb
|
114
|
+
- spec/string_foundation/like_spec.rb
|
106
115
|
- spec/support/enhanced_matchers_extension.rb
|
data/circle.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# ==============================================================================
|
2
|
-
# CIRCLE
|
3
|
-
# ==============================================================================
|
4
|
-
# Settings for CircleCI.
|
5
|
-
machine:
|
6
|
-
environment:
|
7
|
-
CI: true
|
8
|
-
dependencies:
|
9
|
-
pre:
|
10
|
-
- 'case $CIRCLE_NODE_INDEX in 0) rvm use 2.1.0 --default ;; 1) rvm use 2.4.1 --default ;; esac'
|
11
|
-
test:
|
12
|
-
override:
|
13
|
-
- ruby -v ; bundle exec rspec:
|
14
|
-
parallel: true
|
Binary file
|
@@ -1,286 +0,0 @@
|
|
1
|
-
# ==============================================================================
|
2
|
-
# SPEC - STRING FOUNDATION - CONVERTIBLE
|
3
|
-
# ==============================================================================
|
4
|
-
# frozen_string_literal: true
|
5
|
-
describe '[ Convertible Methods ]' do
|
6
|
-
|
7
|
-
# ----------------------------------------------------------------------------
|
8
|
-
# Check Convertible To Integer
|
9
|
-
# ----------------------------------------------------------------------------
|
10
|
-
describe 'CHECK CONVERTIBLE TO INTEGER' do
|
11
|
-
let(:string) { nil }
|
12
|
-
subject { string.to_i? }
|
13
|
-
|
14
|
-
context 'when a string is an integral number,' do
|
15
|
-
context 'and it is a positive number,' do
|
16
|
-
let(:string) { '123' }
|
17
|
-
|
18
|
-
it { is_expected.to eq true }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'and it is a positive number with a sign,' do
|
22
|
-
let(:string) { '+123' }
|
23
|
-
|
24
|
-
it { is_expected.to eq true }
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'and it is a negative number,' do
|
28
|
-
let(:string) { '-5' }
|
29
|
-
|
30
|
-
it { is_expected.to eq true }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when a string is a floating point number,' do
|
35
|
-
context 'and it is a positive number,' do
|
36
|
-
let(:string) { '0.123' }
|
37
|
-
|
38
|
-
it { is_expected.to eq true }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'and it is a positive number with a sign,' do
|
42
|
-
let(:string) { '+0.123' }
|
43
|
-
|
44
|
-
it { is_expected.to eq true }
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'and it is a negative number,' do
|
48
|
-
let(:string) { '-5.123' }
|
49
|
-
|
50
|
-
it { is_expected.to eq true }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when a string is a floating point number without an integer,' do
|
55
|
-
context 'and it is a positive number,' do
|
56
|
-
let(:string) { '.123' }
|
57
|
-
|
58
|
-
it { is_expected.to eq true }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'and it is a positive number with a sign,' do
|
62
|
-
let(:string) { '+.123' }
|
63
|
-
|
64
|
-
it { is_expected.to eq true }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'and it is a negative number,' do
|
68
|
-
let(:string) { '-.123' }
|
69
|
-
|
70
|
-
it { is_expected.to eq true }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when a string a number has leading zeros,' do
|
75
|
-
context 'and it is a positive number,' do
|
76
|
-
let(:string) { '00000123' }
|
77
|
-
|
78
|
-
it { is_expected.to eq true }
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'and it is a positive number with a sign,' do
|
82
|
-
let(:string) { '+00000123' }
|
83
|
-
|
84
|
-
it { is_expected.to eq true }
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'and it is a negative number,' do
|
88
|
-
let(:string) { '-00000123' }
|
89
|
-
|
90
|
-
it { is_expected.to eq true }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'when a string is not a number,' do
|
95
|
-
let(:string) { 'abc' }
|
96
|
-
|
97
|
-
it { is_expected.to eq false }
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
# ----------------------------------------------------------------------------
|
103
|
-
# Check Convertible To Float
|
104
|
-
# ----------------------------------------------------------------------------
|
105
|
-
describe 'CHECK CONVERTIBLE TO FLOAT' do
|
106
|
-
let(:string) { nil }
|
107
|
-
subject { string.to_f? }
|
108
|
-
|
109
|
-
context 'when a string is an integral number,' do
|
110
|
-
context 'and it is a positive number,' do
|
111
|
-
let(:string) { '123' }
|
112
|
-
|
113
|
-
it { is_expected.to eq true }
|
114
|
-
end
|
115
|
-
|
116
|
-
context 'and it is a positive number with a sign,' do
|
117
|
-
let(:string) { '+123' }
|
118
|
-
|
119
|
-
it { is_expected.to eq true }
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'and it is a negative number,' do
|
123
|
-
let(:string) { '-5' }
|
124
|
-
|
125
|
-
it { is_expected.to eq true }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context 'when a string is a floating point number,' do
|
130
|
-
context 'and it is a positive number,' do
|
131
|
-
let(:string) { '0.123' }
|
132
|
-
|
133
|
-
it { is_expected.to eq true }
|
134
|
-
end
|
135
|
-
|
136
|
-
context 'and it is a positive number with a sign,' do
|
137
|
-
let(:string) { '+0.123' }
|
138
|
-
|
139
|
-
it { is_expected.to eq true }
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'and it is a negative number,' do
|
143
|
-
let(:string) { '-5.123' }
|
144
|
-
|
145
|
-
it { is_expected.to eq true }
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'when a string is a floating point number without an integer,' do
|
150
|
-
context 'and it is a positive number,' do
|
151
|
-
let(:string) { '.123' }
|
152
|
-
|
153
|
-
it { is_expected.to eq true }
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'and it is a positive number with a sign,' do
|
157
|
-
let(:string) { '+.123' }
|
158
|
-
|
159
|
-
it { is_expected.to eq true }
|
160
|
-
end
|
161
|
-
|
162
|
-
context 'and it is a negative number,' do
|
163
|
-
let(:string) { '-.123' }
|
164
|
-
|
165
|
-
it { is_expected.to eq true }
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context 'when a string a number has leading zeros,' do
|
170
|
-
context 'and it is a positive number,' do
|
171
|
-
let(:string) { '00000123' }
|
172
|
-
|
173
|
-
it { is_expected.to eq true }
|
174
|
-
end
|
175
|
-
|
176
|
-
context 'and it is a positive number with a sign,' do
|
177
|
-
let(:string) { '+00000123' }
|
178
|
-
|
179
|
-
it { is_expected.to eq true }
|
180
|
-
end
|
181
|
-
|
182
|
-
context 'and it is a negative number,' do
|
183
|
-
let(:string) { '-00000123' }
|
184
|
-
|
185
|
-
it { is_expected.to eq true }
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'when a string is not a number,' do
|
190
|
-
let(:string) { 'abc' }
|
191
|
-
|
192
|
-
it { is_expected.to eq false }
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
|
197
|
-
# ----------------------------------------------------------------------------
|
198
|
-
# Check Convertible To Boolean
|
199
|
-
# ----------------------------------------------------------------------------
|
200
|
-
describe 'CHECK CONVERTIBLE TO BOOLEAN' do
|
201
|
-
let(:string) { nil }
|
202
|
-
subject { string.to_bool? }
|
203
|
-
|
204
|
-
context 'when a string is "true",' do
|
205
|
-
let(:string) { 'true' }
|
206
|
-
|
207
|
-
it { is_expected.to eq true }
|
208
|
-
end
|
209
|
-
|
210
|
-
context 'when a string is "false",' do
|
211
|
-
let(:string) { 'false' }
|
212
|
-
|
213
|
-
it { is_expected.to eq true }
|
214
|
-
end
|
215
|
-
|
216
|
-
context 'when a string is an empty,' do
|
217
|
-
let(:string) { '' }
|
218
|
-
|
219
|
-
it { is_expected.to eq false }
|
220
|
-
end
|
221
|
-
|
222
|
-
context 'when a string is a positive number,' do
|
223
|
-
let(:string) { '1' }
|
224
|
-
|
225
|
-
it { is_expected.to eq false }
|
226
|
-
end
|
227
|
-
|
228
|
-
context 'when a string is a negative number,' do
|
229
|
-
let(:string) { '-1' }
|
230
|
-
|
231
|
-
it { is_expected.to eq false }
|
232
|
-
end
|
233
|
-
|
234
|
-
context 'when a string is not a number,' do
|
235
|
-
let(:string) { 'abc' }
|
236
|
-
|
237
|
-
it { is_expected.to eq false }
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
|
242
|
-
# ----------------------------------------------------------------------------
|
243
|
-
# Check Convertaile To Booly
|
244
|
-
# ----------------------------------------------------------------------------
|
245
|
-
describe 'CHECK CONVERTIBLE TO BOOLYs' do
|
246
|
-
let(:string) { nil }
|
247
|
-
subject { string.to_booly? }
|
248
|
-
|
249
|
-
context 'when a string is "true",' do
|
250
|
-
let(:string) { 'true' }
|
251
|
-
|
252
|
-
it { is_expected.to eq true }
|
253
|
-
end
|
254
|
-
|
255
|
-
context 'when a string is "false",' do
|
256
|
-
let(:string) { 'false' }
|
257
|
-
|
258
|
-
it { is_expected.to eq true }
|
259
|
-
end
|
260
|
-
|
261
|
-
context 'when a string is an empty,' do
|
262
|
-
let(:string) { '' }
|
263
|
-
|
264
|
-
it { is_expected.to eq true }
|
265
|
-
end
|
266
|
-
|
267
|
-
context 'when a string is a positive number,' do
|
268
|
-
let(:string) { '1' }
|
269
|
-
|
270
|
-
it { is_expected.to eq true }
|
271
|
-
end
|
272
|
-
|
273
|
-
context 'when a string is a negative number,' do
|
274
|
-
let(:string) { '-1' }
|
275
|
-
|
276
|
-
it { is_expected.to eq true }
|
277
|
-
end
|
278
|
-
|
279
|
-
context 'when a string is not a number,' do
|
280
|
-
let(:string) { 'abc' }
|
281
|
-
|
282
|
-
it { is_expected.to eq false }
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
end
|