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
data/lib/string_foundation.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - STRING FOUNDATION
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
# Require methods.
|
6
|
-
Dir.glob(File.join(File.dirname(__FILE__),
|
6
|
+
Dir.glob(File.join(File.dirname(__FILE__), "string_foundation", "*.rb")).each do |file|
|
7
|
+
require file
|
8
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# ==============================================================================
|
2
|
+
# LIB - STRING FOUNDATION - BLANK
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
|
+
class String
|
6
|
+
|
7
|
+
# Check whether a string is empty or only half-width spaces.
|
8
|
+
def blank?
|
9
|
+
self.empty? || /\A[[:space:]]*\z/.match(self).instance_of?(MatchData)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Check whether a string is not empty or only half-width spaces.
|
13
|
+
def present?
|
14
|
+
!(self.blank?)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -1,22 +1,21 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - CASE
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
class String
|
6
6
|
|
7
7
|
# Convert to lowerCamelCase.
|
8
8
|
def to_lcamel
|
9
9
|
ucamel = self.to_ucamel
|
10
|
-
ucamel.make_head_lower
|
10
|
+
ucamel.instance_eval { make_head_lower }
|
11
11
|
end
|
12
12
|
|
13
13
|
# Convert to UpperCamelCase.
|
14
14
|
def to_ucamel
|
15
|
-
|
16
|
-
cw.split(/\.|_|-|\s/).map
|
17
|
-
|
18
|
-
|
19
|
-
end.join
|
15
|
+
split_camel.map do |cw|
|
16
|
+
cw.split(/\.|_|-|\s/).map { |w| w.capitalize }.join
|
17
|
+
end
|
18
|
+
.join
|
20
19
|
end
|
21
20
|
|
22
21
|
# Convert to lower_snake_case.
|
@@ -27,11 +26,10 @@ class String
|
|
27
26
|
|
28
27
|
# Convert to Upper_Snake_Case.
|
29
28
|
def to_usnake
|
30
|
-
|
31
|
-
cw.split(/\.|_|-|\s/).map
|
32
|
-
|
33
|
-
|
34
|
-
end.join('_')
|
29
|
+
split_camel.map do |cw|
|
30
|
+
cw.split(/\.|_|-|\s/).map { |w| w.capitalize }.join("_")
|
31
|
+
end
|
32
|
+
.join("_")
|
35
33
|
end
|
36
34
|
|
37
35
|
# Convert to lower-kebab-case.
|
@@ -42,11 +40,10 @@ class String
|
|
42
40
|
|
43
41
|
# Convert to Upper-Kebab-Case.
|
44
42
|
def to_ukebab
|
45
|
-
|
46
|
-
cw.split(/\.|_|-|\s/).map
|
47
|
-
|
48
|
-
|
49
|
-
end.join('-')
|
43
|
+
split_camel.map do |cw|
|
44
|
+
cw.split(/\.|_|-|\s/).map { |w| w.capitalize }.join("-")
|
45
|
+
end
|
46
|
+
.join("-")
|
50
47
|
end
|
51
48
|
|
52
49
|
# Convert to lower space case.
|
@@ -57,11 +54,10 @@ class String
|
|
57
54
|
|
58
55
|
# Convert to Upper Space Case.
|
59
56
|
def to_uspace
|
60
|
-
|
61
|
-
cw.split(/\.|_|-|\s/).map
|
62
|
-
|
63
|
-
|
64
|
-
end.join(' ')
|
57
|
+
split_camel.map do |cw|
|
58
|
+
cw.split(/\.|_|-|\s/).map { |w| w.capitalize }.join(" ")
|
59
|
+
end
|
60
|
+
.join(" ")
|
65
61
|
end
|
66
62
|
|
67
63
|
# Convert to lower.dot.case.
|
@@ -72,26 +68,20 @@ class String
|
|
72
68
|
|
73
69
|
# Convert to Upper.Dot.Case.
|
74
70
|
def to_udot
|
75
|
-
|
76
|
-
cw.split(/\.|_|-|\s/).map
|
77
|
-
|
78
|
-
|
79
|
-
end.join('.')
|
71
|
+
split_camel.map do |cw|
|
72
|
+
cw.split(/\.|_|-|\s/).map { |w| w.capitalize }.join(".")
|
73
|
+
end
|
74
|
+
.join(".")
|
80
75
|
end
|
81
76
|
|
77
|
+
|
78
|
+
# ----------------------------------------------------------------------------
|
79
|
+
# Private
|
80
|
+
# ----------------------------------------------------------------------------
|
81
|
+
private
|
82
82
|
# Split string according to camel case.
|
83
83
|
def split_camel
|
84
|
-
self.split
|
85
|
-
end
|
86
|
-
|
87
|
-
# Whether a character is uppder case or not.
|
88
|
-
def is_upper?
|
89
|
-
/[[:upper:]]/.match(self) ? true : false
|
90
|
-
end
|
91
|
-
|
92
|
-
# Whether a character is lower case or not.
|
93
|
-
def is_lower?
|
94
|
-
/[[:lower:]]/.match(self) ? true : false
|
84
|
+
self.split(/(?=[A-Z])/)
|
95
85
|
end
|
96
86
|
|
97
87
|
# Make first character lower case.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - CONVERT
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
5
|
-
|
6
|
-
require_relative
|
7
|
-
require_relative
|
4
|
+
# ==============================================================================
|
5
|
+
require_relative "convertible"
|
6
|
+
require_relative "like"
|
7
|
+
require_relative "with"
|
8
8
|
class String
|
9
9
|
|
10
10
|
# Convert to TrueClass or FalseClass.
|
@@ -13,7 +13,7 @@ class String
|
|
13
13
|
raise TypeError.new("#{self} cannot be converted to TrueClass or FalseClass")
|
14
14
|
end
|
15
15
|
|
16
|
-
(self ==
|
16
|
+
(self == "true")
|
17
17
|
end
|
18
18
|
|
19
19
|
# Convert a booly string to TrueClass or FalseClass.
|
@@ -22,7 +22,7 @@ class String
|
|
22
22
|
raise TypeError.new("#{self} cannot be converted to TrueClass or FalseClass")
|
23
23
|
end
|
24
24
|
|
25
|
-
return true if self ==
|
25
|
+
return true if self == "true" || (self.to_f? && self.to_f > 0)
|
26
26
|
false
|
27
27
|
end
|
28
28
|
|
@@ -30,20 +30,20 @@ class String
|
|
30
30
|
def to_pretty
|
31
31
|
return self.without_leading_zeros.to_i if self.like_i?
|
32
32
|
return self.without_leading_zeros.to_f if self.like_f?
|
33
|
-
return self.to_bool
|
33
|
+
return self.to_bool if self.to_bool?
|
34
34
|
|
35
35
|
(self.length > 0) ? self : nil
|
36
36
|
end
|
37
37
|
|
38
38
|
# Convert from newline character to specific characters.
|
39
39
|
def nl_to(char)
|
40
|
-
char =
|
40
|
+
char = "" if char.nil?
|
41
41
|
self.gsub(/(\r\n|\n)/, char)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Convert from newline character to a HTML tag "<br>".
|
45
45
|
def nl_to_br
|
46
|
-
self.nl_to(
|
46
|
+
self.nl_to("<br>")
|
47
47
|
end
|
48
48
|
|
49
49
|
alias_method :nl2, :nl_to
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - CONVERTIBLE
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
5
|
-
|
4
|
+
# ==============================================================================
|
5
|
+
require_relative "with"
|
6
6
|
class String
|
7
7
|
|
8
8
|
# Whether or not to be possible to covert String to Integer.
|
@@ -23,7 +23,7 @@ class String
|
|
23
23
|
|
24
24
|
# Whether or not to be possible to covert String to Boolean.
|
25
25
|
def to_bool?
|
26
|
-
return true if
|
26
|
+
return true if ["true", "false"].include?(self)
|
27
27
|
false
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ class String
|
|
31
31
|
# like boolean types.
|
32
32
|
def to_booly?
|
33
33
|
return true if self.length == 0
|
34
|
-
return true if
|
34
|
+
return true if ["true", "false"].include?(self)
|
35
35
|
return true if self.to_f?
|
36
36
|
|
37
37
|
false
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# ==============================================================================
|
2
|
+
# LIB - STRING FOUNDATION - IS
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
|
+
class String
|
6
|
+
|
7
|
+
def is_sym?(symbol)
|
8
|
+
raise ArgumentError.new("argument must be Symbol") unless symbol.instance_of?(Symbol)
|
9
|
+
|
10
|
+
(self == symbol.to_s)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# ==============================================================================
|
2
|
+
# LIB - STRING FOUNDATION - LENGTH
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
|
+
class String
|
6
|
+
|
7
|
+
# Check whether characters length is a specific number.
|
8
|
+
def length?(length)
|
9
|
+
unless [Integer, Range, Fixnum, Bignum].include?(length.class)
|
10
|
+
raise ArgumentError.new("argument must be Integer (including Fixnum or Bignum) or Range")
|
11
|
+
end
|
12
|
+
|
13
|
+
return (self.length == length) unless length.instance_of?(Range)
|
14
|
+
self.length.between?(length.first, length.last)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Check whether characters length is less than a specific number.
|
18
|
+
def length_lt?(length)
|
19
|
+
self.instance_eval { allow_only_integer(length) }
|
20
|
+
|
21
|
+
(self.length < length)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Check whether characters length is less than or equal to a specific number.
|
25
|
+
def length_lte?(length)
|
26
|
+
self.instance_eval { allow_only_integer(length) }
|
27
|
+
|
28
|
+
(self.length <= length)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check whether characters length is greater than a specific number.
|
32
|
+
def length_gt?(length)
|
33
|
+
self.instance_eval { allow_only_integer(length) }
|
34
|
+
|
35
|
+
(self.length > length)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Check whether characters length is greater than or equal to a specific number.
|
39
|
+
def length_gte?(length)
|
40
|
+
self.instance_eval { allow_only_integer(length) }
|
41
|
+
|
42
|
+
(self.length >= length)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# ----------------------------------------------------------------------------
|
47
|
+
# Private
|
48
|
+
# ----------------------------------------------------------------------------
|
49
|
+
private
|
50
|
+
# Allow only Integer.
|
51
|
+
def allow_only_integer(argument)
|
52
|
+
return if [Integer, Fixnum, Bignum].include?(argument.class)
|
53
|
+
raise ArgumentError.new("argument must be Integer (including Fixnum or Bignum)")
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - LIKE
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
5
|
-
|
4
|
+
# ==============================================================================
|
5
|
+
require_relative "convertible"
|
6
6
|
class String
|
7
7
|
|
8
8
|
# Check whether a string is an integral number.
|
@@ -10,7 +10,7 @@ class String
|
|
10
10
|
return false unless self.to_i?
|
11
11
|
|
12
12
|
num = self.without_leading_zeros
|
13
|
-
(num.to_i == num.to_i) && !num.include?(
|
13
|
+
(num.to_i == num.to_i) && !num.include?(".")
|
14
14
|
end
|
15
15
|
|
16
16
|
# Check whether a string is a floating point number.
|
@@ -18,7 +18,7 @@ class String
|
|
18
18
|
return false unless self.to_f?
|
19
19
|
|
20
20
|
num = self.without_leading_zeros
|
21
|
-
(num.to_i != num.to_f) || num.include?(
|
21
|
+
(num.to_i != num.to_f) || num.include?(".")
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - VERSION
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
module StringFoundation
|
6
|
-
VERSION =
|
6
|
+
VERSION = "1.1.0"
|
7
7
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# LIB - STRING FOUNDATION - WITH
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
class String
|
6
6
|
|
7
7
|
# Remove leading zeros.
|
8
8
|
def without_leading_zeros
|
9
|
-
return self if self ==
|
9
|
+
return self if self == "0"
|
10
10
|
|
11
|
-
is_positive = self.start_with?(
|
12
|
-
is_negative = self.start_with?(
|
11
|
+
is_positive = self.start_with?("0")
|
12
|
+
is_negative = self.start_with?("-0")
|
13
13
|
if is_positive || is_negative
|
14
|
-
sig = self[0, self.length].gsub(/(^0+)|(^-0+)/,
|
14
|
+
sig = self[0, self.length].gsub(/(^0+)|(^-0+)/, "")
|
15
15
|
|
16
|
-
sig =
|
17
|
-
sig =
|
16
|
+
sig = "0" + sig if sig.start_with?(".") || sig.length == 0
|
17
|
+
sig = "-" + sig if is_negative && sig != "0"
|
18
18
|
|
19
19
|
sig
|
20
20
|
else
|
Binary file
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# ==============================================================================
|
2
2
|
# SPEC - SPEC HELPER
|
3
|
-
# ==============================================================================
|
4
3
|
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
5
|
# Configure Simple Cov to get coverage and Codecov.
|
6
6
|
# !! These should be written at the beginning of this file to work. !!
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
if ENV[
|
7
|
+
require "simplecov"
|
8
|
+
require "simplecov-console"
|
9
|
+
require "codecov"
|
10
|
+
if ENV["CI"]
|
11
11
|
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
12
12
|
else
|
13
13
|
SimpleCov.formatters = [
|
@@ -18,12 +18,12 @@ end
|
|
18
18
|
SimpleCov.start
|
19
19
|
|
20
20
|
# Require core files.
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
21
|
+
require "bundler/setup"
|
22
|
+
require "string_foundation"
|
23
|
+
require "support/enhanced_matchers_extension"
|
24
24
|
|
25
25
|
# Require components.
|
26
|
-
require
|
26
|
+
require "random_token"
|
27
27
|
|
28
28
|
# ------------------------------------------------------------------------------
|
29
29
|
# RSpec Settings
|
@@ -32,7 +32,7 @@ RSpec.configure do |config|
|
|
32
32
|
config.include EnhancedMatchersExtension
|
33
33
|
|
34
34
|
# Enable flags like --only-failures and --next-failure .
|
35
|
-
config.example_status_persistence_file_path =
|
35
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
36
36
|
|
37
37
|
config.expect_with :rspec do |c|
|
38
38
|
c.syntax = :expect
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# ==============================================================================
|
2
|
+
# SPEC - STRING FOUNDATION - BLANK SPEC
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# ==============================================================================
|
5
|
+
describe "[ Blank Methods ]" do
|
6
|
+
let(:string) { "" }
|
7
|
+
|
8
|
+
# ----------------------------------------------------------------------------
|
9
|
+
# Check Whether A String Is A Blank
|
10
|
+
# ----------------------------------------------------------------------------
|
11
|
+
describe "CHECK WHETHER A STRING IS A BLANK ::" do
|
12
|
+
subject { string.blank? }
|
13
|
+
|
14
|
+
context "when a string is empty," do
|
15
|
+
it { is_expected.to be true }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when a string is a word," do
|
19
|
+
let(:string) { "string" }
|
20
|
+
|
21
|
+
it { is_expected.to be false }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when a string includes half-width spaces," do
|
25
|
+
let(:string) { "this is string foundation." }
|
26
|
+
|
27
|
+
it { is_expected.to be false }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when a string includes only 1 half-width space," do
|
31
|
+
let(:string) { " " }
|
32
|
+
|
33
|
+
it { is_expected.to be true }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when a string includes only multiple half-width spaces," do
|
37
|
+
let(:string) { " " * 3 }
|
38
|
+
|
39
|
+
it { is_expected.to be true }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when a string is a newline," do
|
43
|
+
let(:string) { "\n" }
|
44
|
+
|
45
|
+
it { is_expected.to be true }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# ----------------------------------------------------------------------------
|
51
|
+
# Check Whether A String Is Present
|
52
|
+
# ----------------------------------------------------------------------------
|
53
|
+
describe "CHECK WHETHER A STRING IS PRESENT ::" do
|
54
|
+
subject { string.present? }
|
55
|
+
|
56
|
+
context "when a string is empty," do
|
57
|
+
it { is_expected.to be false }
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when a string is a word," do
|
61
|
+
let(:string) { "string" }
|
62
|
+
|
63
|
+
it { is_expected.to be true }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when a string includes half-width spaces," do
|
67
|
+
let(:string) { "this is string foundation." }
|
68
|
+
|
69
|
+
it { is_expected.to be true }
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when a string includes only 1 half-width space," do
|
73
|
+
let(:string) { " " }
|
74
|
+
|
75
|
+
it { is_expected.to be false }
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when a string includes only multiple half-width spaces," do
|
79
|
+
let(:string) { " " * 3 }
|
80
|
+
|
81
|
+
it { is_expected.to be false }
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when a string is a newline," do
|
85
|
+
let(:string) { "\n" }
|
86
|
+
|
87
|
+
it { is_expected.to be false }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|