string_foundation 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,62 @@
|
|
1
|
+
# ==============================================================================
|
2
|
+
# SPEC - STRING FOUNDATION - IS SPEC
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
|
+
describe "[ Is Methods ]" do
|
6
|
+
let(:string) { "string" }
|
7
|
+
let(:expected_symbol) { :string }
|
8
|
+
|
9
|
+
# ----------------------------------------------------------------------------
|
10
|
+
# Check Whether Character Is A Specific Symbol
|
11
|
+
# ----------------------------------------------------------------------------
|
12
|
+
describe "CHECK WHETHER CHARACTER IS A SPECIFIC SYMBOL ::" do
|
13
|
+
subject { string.is_sym?(expected_symbol) }
|
14
|
+
|
15
|
+
context "when an argument is not a Symbol," do
|
16
|
+
let(:expected_symbol) { "string" }
|
17
|
+
|
18
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when an object equal to an argument," do
|
22
|
+
context "object and argument are alphabets," do
|
23
|
+
it { is_expected.to be true }
|
24
|
+
end
|
25
|
+
|
26
|
+
context "object and argument are numbers," do
|
27
|
+
let(:string) { "123" }
|
28
|
+
let(:expected_symbol) { :"123" }
|
29
|
+
|
30
|
+
it { is_expected.to be true }
|
31
|
+
end
|
32
|
+
|
33
|
+
context "object and argument are empty," do
|
34
|
+
let(:string) { "" }
|
35
|
+
let(:expected_symbol) { :"" }
|
36
|
+
|
37
|
+
it { is_expected.to be true }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "object and argument include underscores," do
|
41
|
+
let(:string) { "string_foundation" }
|
42
|
+
let(:expected_symbol) { :string_foundation }
|
43
|
+
|
44
|
+
it { is_expected.to be true }
|
45
|
+
end
|
46
|
+
|
47
|
+
context "object and argument include dashes," do
|
48
|
+
let(:string) { "string-foundation" }
|
49
|
+
let(:expected_symbol) { :"string-foundation" }
|
50
|
+
|
51
|
+
it { is_expected.to be true }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when an object is not equal to an argument," do
|
56
|
+
let(:expected_symbol) { :integer }
|
57
|
+
|
58
|
+
it { is_expected.to be false }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
# ==============================================================================
|
2
|
+
# SPEC - STRING FOUNDATION - LENGTH SPEC
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
|
+
describe "[ Length Methods ]" do
|
6
|
+
let(:string) { "string" }
|
7
|
+
let(:expected_length) { 0 }
|
8
|
+
|
9
|
+
# ----------------------------------------------------------------------------
|
10
|
+
# Check Whether Characters Length Is A Specific Number
|
11
|
+
# ----------------------------------------------------------------------------
|
12
|
+
describe "CHECK WHETHER CHARACTERS LENGTH IS A SPECIFIC NUMBER ::" do
|
13
|
+
subject { string.length?(expected_length) }
|
14
|
+
|
15
|
+
context "when an argument is String," do
|
16
|
+
let(:expected_length) { string.length.to_s }
|
17
|
+
|
18
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when an argument is Integer," do
|
22
|
+
context "characters length is equal to an argument," do
|
23
|
+
let(:expected_length) { string.length }
|
24
|
+
|
25
|
+
it { is_expected.to be true }
|
26
|
+
end
|
27
|
+
|
28
|
+
context "characters length is less than an argument," do
|
29
|
+
let(:expected_length) { string.length + 1 }
|
30
|
+
|
31
|
+
it { is_expected.to be false }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "characters length is greater than an argument," do
|
35
|
+
let(:expected_length) { string.length - 1 }
|
36
|
+
|
37
|
+
it { is_expected.to be false }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when an argument is Range," do
|
42
|
+
context "characters length is in range," do
|
43
|
+
let(:expected_length) { (string.length - 1)..(string.length + 1) }
|
44
|
+
|
45
|
+
it { is_expected.to be true }
|
46
|
+
end
|
47
|
+
|
48
|
+
context "characters length is equal to the minimum of range," do
|
49
|
+
let(:expected_length) { string.length..(string.length + 1) }
|
50
|
+
|
51
|
+
it { is_expected.to be true }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "characters length is equal to the maximum of range," do
|
55
|
+
let(:expected_length) { (string.length - 1)..string.length }
|
56
|
+
|
57
|
+
it { is_expected.to be true }
|
58
|
+
end
|
59
|
+
|
60
|
+
context "characters length is less than the minimum of range," do
|
61
|
+
let(:expected_length) { (string.length + 1)..(string.length + 2) }
|
62
|
+
|
63
|
+
it { is_expected.to be false }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "characters length is greater than the maximum of range," do
|
67
|
+
let(:expected_length) { (string.length - 2)..(string.length - 1) }
|
68
|
+
|
69
|
+
it { is_expected.to be false }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
# ----------------------------------------------------------------------------
|
76
|
+
# Check Whether Characters Length Is Less Than A Specific Number
|
77
|
+
# ----------------------------------------------------------------------------
|
78
|
+
describe "CHECK WHETHER CHARACTERS LENGTH IS LESS THAN A SPECIFIC NUMBER ::" do
|
79
|
+
subject { string.length_lt?(expected_length) }
|
80
|
+
|
81
|
+
context "when an argument is String," do
|
82
|
+
let(:expected_length) { string.length.to_s }
|
83
|
+
|
84
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when an argument is Range," do
|
88
|
+
let(:expected_length) { (string.length - 1)..(string.length + 1) }
|
89
|
+
|
90
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when characters length is less than an argument," do
|
94
|
+
let(:expected_length) { string.length + 1 }
|
95
|
+
|
96
|
+
it { is_expected.to be true }
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when characters length is equal to an argument," do
|
100
|
+
let(:expected_length) { string.length }
|
101
|
+
|
102
|
+
it { is_expected.to be false }
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when characters length is greater than an argument," do
|
106
|
+
let(:expected_length) { string.length - 1 }
|
107
|
+
|
108
|
+
it { is_expected.to be false }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
# ----------------------------------------------------------------------------
|
114
|
+
# Check Whether Characters Length Is Less Than Or Equal To A Specific Number
|
115
|
+
# ----------------------------------------------------------------------------
|
116
|
+
describe "CHECK WHETHER CHARACTERS LENGTH IS LESS THAN OR EQUAL TO A SPECIFIC NUMBER ::" do
|
117
|
+
subject { string.length_lte?(expected_length) }
|
118
|
+
|
119
|
+
context "when an argument is String," do
|
120
|
+
let(:expected_length) { string.length.to_s }
|
121
|
+
|
122
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
123
|
+
end
|
124
|
+
|
125
|
+
context "when an argument is Range," do
|
126
|
+
let(:expected_length) { (string.length - 1)..(string.length + 1) }
|
127
|
+
|
128
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
129
|
+
end
|
130
|
+
|
131
|
+
context "when characters length is equal to an argument," do
|
132
|
+
let(:expected_length) { string.length }
|
133
|
+
|
134
|
+
it { is_expected.to be true }
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when characters length is less than an argument," do
|
138
|
+
let(:expected_length) { string.length + 1 }
|
139
|
+
|
140
|
+
it { is_expected.to be true }
|
141
|
+
end
|
142
|
+
|
143
|
+
context "when characters length is greater than an argument," do
|
144
|
+
let(:expected_length) { string.length - 1 }
|
145
|
+
|
146
|
+
it { is_expected.to be false }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
# ----------------------------------------------------------------------------
|
152
|
+
# Check Whether Characters Length Is Greater Than A Specific Number
|
153
|
+
# ----------------------------------------------------------------------------
|
154
|
+
describe "CHECK WHETHER CHARACTERS LENGTH IS GREATER THAN A SPECIFIC NUMBER ::" do
|
155
|
+
subject { string.length_gt?(expected_length) }
|
156
|
+
|
157
|
+
context "when an argument is String," do
|
158
|
+
let(:expected_length) { string.length.to_s }
|
159
|
+
|
160
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
161
|
+
end
|
162
|
+
|
163
|
+
context "when an argument is Range," do
|
164
|
+
let(:expected_length) { (string.length - 1)..(string.length + 1) }
|
165
|
+
|
166
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
167
|
+
end
|
168
|
+
|
169
|
+
context "when characters length is greater than an argument," do
|
170
|
+
let(:expected_length) { string.length - 1 }
|
171
|
+
|
172
|
+
it { is_expected.to be true }
|
173
|
+
end
|
174
|
+
|
175
|
+
context "when characters length is equal to an argument," do
|
176
|
+
let(:expected_length) { string.length }
|
177
|
+
|
178
|
+
it { is_expected.to be false }
|
179
|
+
end
|
180
|
+
|
181
|
+
context "when characters length is less than an argument," do
|
182
|
+
let(:expected_length) { string.length + 1 }
|
183
|
+
|
184
|
+
it { is_expected.to be false }
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
# ----------------------------------------------------------------------------
|
190
|
+
# Check Whether Characters Length Is Greater Than Or Equal To A Specific Number
|
191
|
+
# ----------------------------------------------------------------------------
|
192
|
+
describe "CHECK WHETHER CHARACTERS LENGTH IS GREATER THAN OR EQUAL TO A SPECIFIC NUMBER ::" do
|
193
|
+
subject { string.length_gte?(expected_length) }
|
194
|
+
|
195
|
+
context "when an argument is String," do
|
196
|
+
let(:expected_length) { string.length.to_s }
|
197
|
+
|
198
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
199
|
+
end
|
200
|
+
|
201
|
+
context "when an argument is Range," do
|
202
|
+
let(:expected_length) { (string.length - 1)..(string.length + 1) }
|
203
|
+
|
204
|
+
it { is_expected_as_block.to raise_error(ArgumentError) }
|
205
|
+
end
|
206
|
+
|
207
|
+
context "when characters length is equal to an argument," do
|
208
|
+
let(:expected_length) { string.length }
|
209
|
+
|
210
|
+
it { is_expected.to be true }
|
211
|
+
end
|
212
|
+
|
213
|
+
context "when characters length is greater than an argument," do
|
214
|
+
let(:expected_length) { string.length - 1 }
|
215
|
+
|
216
|
+
it { is_expected.to be true }
|
217
|
+
end
|
218
|
+
|
219
|
+
context "when characters length is less than an argument," do
|
220
|
+
let(:expected_length) { string.length + 1 }
|
221
|
+
|
222
|
+
it { is_expected.to be false }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
@@ -1,218 +1,218 @@
|
|
1
1
|
# ==============================================================================
|
2
|
-
# SPEC - STRING FOUNDATION - LIKE
|
3
|
-
# ==============================================================================
|
2
|
+
# SPEC - STRING FOUNDATION - LIKE SPEC
|
4
3
|
# frozen_string_literal: true
|
5
|
-
|
4
|
+
# ==============================================================================
|
5
|
+
describe "[ Like Methods ]" do
|
6
6
|
|
7
7
|
# ----------------------------------------------------------------------------
|
8
8
|
# Check Whether A String Is Integer
|
9
9
|
# ----------------------------------------------------------------------------
|
10
|
-
describe
|
10
|
+
describe "CHECK WHETHER A STRING IS INTEGER ::" do
|
11
11
|
let(:string) { nil }
|
12
12
|
subject { string.like_i? }
|
13
13
|
|
14
|
-
context
|
15
|
-
context
|
16
|
-
let(:string) {
|
14
|
+
context "when a string is an integral number," do
|
15
|
+
context "it is a positive number," do
|
16
|
+
let(:string) { "123" }
|
17
17
|
|
18
|
-
it { is_expected.to
|
18
|
+
it { is_expected.to be true }
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
22
|
-
let(:string) {
|
21
|
+
context "it is a positive number with a sign," do
|
22
|
+
let(:string) { "+123" }
|
23
23
|
|
24
|
-
it { is_expected.to
|
24
|
+
it { is_expected.to be true }
|
25
25
|
end
|
26
26
|
|
27
|
-
context
|
28
|
-
let(:string) {
|
27
|
+
context "it is a negative number," do
|
28
|
+
let(:string) { "-5" }
|
29
29
|
|
30
|
-
it { is_expected.to
|
30
|
+
it { is_expected.to be true }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
context
|
35
|
-
context
|
36
|
-
let(:string) {
|
34
|
+
context "when a string is a floating point number," do
|
35
|
+
context "it is a positive number," do
|
36
|
+
let(:string) { "0.123" }
|
37
37
|
|
38
|
-
it { is_expected.to
|
38
|
+
it { is_expected.to be false }
|
39
39
|
end
|
40
40
|
|
41
|
-
context
|
42
|
-
let(:string) {
|
41
|
+
context "it is a positive number with a sign," do
|
42
|
+
let(:string) { "+0.123" }
|
43
43
|
|
44
|
-
it { is_expected.to
|
44
|
+
it { is_expected.to be false }
|
45
45
|
end
|
46
46
|
|
47
|
-
context
|
48
|
-
let(:string) {
|
47
|
+
context "it is a negative number," do
|
48
|
+
let(:string) { "-5.123" }
|
49
49
|
|
50
|
-
it { is_expected.to
|
50
|
+
it { is_expected.to be false }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
context
|
55
|
-
context
|
56
|
-
let(:string) {
|
54
|
+
context "when a string is a floating point number without an integer," do
|
55
|
+
context "it is a positive number," do
|
56
|
+
let(:string) { ".123" }
|
57
57
|
|
58
|
-
it { is_expected.to
|
58
|
+
it { is_expected.to be false }
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
62
|
-
let(:string) {
|
61
|
+
context "it is a positive number with a sign," do
|
62
|
+
let(:string) { "+.123" }
|
63
63
|
|
64
|
-
it { is_expected.to
|
64
|
+
it { is_expected.to be false }
|
65
65
|
end
|
66
66
|
|
67
|
-
context
|
68
|
-
let(:string) {
|
67
|
+
context "it is a negative number," do
|
68
|
+
let(:string) { "-.123" }
|
69
69
|
|
70
|
-
it { is_expected.to
|
70
|
+
it { is_expected.to be false }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
context
|
75
|
-
context
|
76
|
-
let(:string) {
|
74
|
+
context "when a string a number has leading zeros," do
|
75
|
+
context "it is a positive number," do
|
76
|
+
let(:string) { "00000123" }
|
77
77
|
|
78
|
-
it { is_expected.to
|
78
|
+
it { is_expected.to be true }
|
79
79
|
end
|
80
80
|
|
81
|
-
context
|
82
|
-
let(:string) {
|
81
|
+
context "it is a positive number with a sign," do
|
82
|
+
let(:string) { "+00000123" }
|
83
83
|
|
84
|
-
it { is_expected.to
|
84
|
+
it { is_expected.to be true }
|
85
85
|
end
|
86
86
|
|
87
|
-
context
|
88
|
-
let(:string) {
|
87
|
+
context "it is a negative number," do
|
88
|
+
let(:string) { "-00000123" }
|
89
89
|
|
90
|
-
it { is_expected.to
|
90
|
+
it { is_expected.to be true }
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
context
|
95
|
-
let(:string) {
|
94
|
+
context "when a string is 0," do
|
95
|
+
let(:string) { "0" }
|
96
96
|
|
97
|
-
it { is_expected.to
|
97
|
+
it { is_expected.to be true }
|
98
98
|
end
|
99
99
|
|
100
|
-
context
|
101
|
-
let(:string) {
|
100
|
+
context "when a string is 0.0," do
|
101
|
+
let(:string) { "0.0" }
|
102
102
|
|
103
|
-
it { is_expected.to
|
103
|
+
it { is_expected.to be false }
|
104
104
|
end
|
105
105
|
|
106
|
-
context
|
107
|
-
let(:string) {
|
106
|
+
context "when a string is not a number," do
|
107
|
+
let(:string) { "abc" }
|
108
108
|
|
109
|
-
it { is_expected.to
|
109
|
+
it { is_expected.to be false }
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
# ----------------------------------------------------------------------------
|
114
114
|
# Check Whether A String Is Float
|
115
115
|
# ----------------------------------------------------------------------------
|
116
|
-
describe
|
116
|
+
describe "CHECK WHETHER A STRING IS FLOAT ::" do
|
117
117
|
let(:string) { nil }
|
118
118
|
subject { string.like_f? }
|
119
119
|
|
120
|
-
context
|
121
|
-
context
|
122
|
-
let(:string) {
|
120
|
+
context "when a string is an integral number," do
|
121
|
+
context "it is a positive number," do
|
122
|
+
let(:string) { "123" }
|
123
123
|
|
124
|
-
it { is_expected.to
|
124
|
+
it { is_expected.to be false }
|
125
125
|
end
|
126
126
|
|
127
|
-
context
|
128
|
-
let(:string) {
|
127
|
+
context "it is a positive number with a sign," do
|
128
|
+
let(:string) { "+123" }
|
129
129
|
|
130
|
-
it { is_expected.to
|
130
|
+
it { is_expected.to be false }
|
131
131
|
end
|
132
132
|
|
133
|
-
context
|
134
|
-
let(:string) {
|
133
|
+
context "it is a negative number," do
|
134
|
+
let(:string) { "-5" }
|
135
135
|
|
136
|
-
it { is_expected.to
|
136
|
+
it { is_expected.to be false }
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
context
|
141
|
-
context
|
142
|
-
let(:string) {
|
140
|
+
context "when a string is a floating point number," do
|
141
|
+
context "it is a positive number," do
|
142
|
+
let(:string) { "0.123" }
|
143
143
|
|
144
|
-
it { is_expected.to
|
144
|
+
it { is_expected.to be true }
|
145
145
|
end
|
146
146
|
|
147
|
-
context
|
148
|
-
let(:string) {
|
147
|
+
context "it is a positive number with a sign," do
|
148
|
+
let(:string) { "+0.123" }
|
149
149
|
|
150
|
-
it { is_expected.to
|
150
|
+
it { is_expected.to be true }
|
151
151
|
end
|
152
152
|
|
153
|
-
context
|
154
|
-
let(:string) {
|
153
|
+
context "it is a negative number," do
|
154
|
+
let(:string) { "-5.123" }
|
155
155
|
|
156
|
-
it { is_expected.to
|
156
|
+
it { is_expected.to be true }
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
context
|
161
|
-
context
|
162
|
-
let(:string) {
|
160
|
+
context "when a string is a floating point number without an integer," do
|
161
|
+
context "it is a positive number," do
|
162
|
+
let(:string) { ".123" }
|
163
163
|
|
164
|
-
it { is_expected.to
|
164
|
+
it { is_expected.to be true }
|
165
165
|
end
|
166
166
|
|
167
|
-
context
|
168
|
-
let(:string) {
|
167
|
+
context "it is a positive number with a sign," do
|
168
|
+
let(:string) { "+.123" }
|
169
169
|
|
170
|
-
it { is_expected.to
|
170
|
+
it { is_expected.to be true }
|
171
171
|
end
|
172
172
|
|
173
|
-
context
|
174
|
-
let(:string) {
|
173
|
+
context "it is a negative number," do
|
174
|
+
let(:string) { "-.123" }
|
175
175
|
|
176
|
-
it { is_expected.to
|
176
|
+
it { is_expected.to be true }
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
-
context
|
181
|
-
context
|
182
|
-
let(:string) {
|
180
|
+
context "when a string a number has leading zeros," do
|
181
|
+
context "it is a positive number," do
|
182
|
+
let(:string) { "00000123" }
|
183
183
|
|
184
|
-
it { is_expected.to
|
184
|
+
it { is_expected.to be false }
|
185
185
|
end
|
186
186
|
|
187
|
-
context
|
188
|
-
let(:string) {
|
187
|
+
context "it is a positive number with a sign," do
|
188
|
+
let(:string) { "+00000123" }
|
189
189
|
|
190
|
-
it { is_expected.to
|
190
|
+
it { is_expected.to be false }
|
191
191
|
end
|
192
192
|
|
193
|
-
context
|
194
|
-
let(:string) {
|
193
|
+
context "it is a negative number," do
|
194
|
+
let(:string) { "-00000123" }
|
195
195
|
|
196
|
-
it { is_expected.to
|
196
|
+
it { is_expected.to be false }
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
-
context
|
201
|
-
let(:string) {
|
200
|
+
context "when a string is 0," do
|
201
|
+
let(:string) { "0" }
|
202
202
|
|
203
|
-
it { is_expected.to
|
203
|
+
it { is_expected.to be false }
|
204
204
|
end
|
205
205
|
|
206
|
-
context
|
207
|
-
let(:string) {
|
206
|
+
context "when a string is 0.0," do
|
207
|
+
let(:string) { "0.0" }
|
208
208
|
|
209
|
-
it { is_expected.to
|
209
|
+
it { is_expected.to be true }
|
210
210
|
end
|
211
211
|
|
212
|
-
context
|
213
|
-
let(:string) {
|
212
|
+
context "when a string is not a number," do
|
213
|
+
let(:string) { "abc" }
|
214
214
|
|
215
|
-
it { is_expected.to
|
215
|
+
it { is_expected.to be false }
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|