fat_core 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fat_core/period.rb +9 -0
- data/lib/fat_core/version.rb +1 -1
- data/spec/lib/date_spec.rb +158 -167
- data/spec/lib/numeric_spec.rb +9 -9
- data/spec/lib/period_spec.rb +139 -137
- data/spec/lib/range_spec.rb +53 -53
- data/spec/lib/string_spec.rb +27 -27
- data/spec/spec_helper.rb +2 -1
- metadata +2 -2
data/spec/lib/string_spec.rb
CHANGED
@@ -56,68 +56,68 @@ the people, for the people, shall not perish from the earth."
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should wrap a short string" do
|
59
|
-
"hello, world".wrap.
|
59
|
+
expect("hello, world".wrap).to eq "hello, world"
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should wrap a long string" do
|
63
|
-
@getty.wrap.split("\n").each {|l| l.length.
|
63
|
+
@getty.wrap.split("\n").each {|l| expect(l.length).to be <= 70}
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should wrap a long string with a hangining indent" do
|
67
|
-
@getty.wrap(70, 10).split("\n").each {|l| l.length.
|
67
|
+
@getty.wrap(70, 10).split("\n").each {|l| expect(l.length).to be <= 70}
|
68
68
|
@getty.wrap(70, 10).split("\n")[1..-1].each do |l|
|
69
|
-
l.
|
69
|
+
expect(l).to match(/^ /)
|
70
70
|
end
|
71
71
|
second_line = ' ' * 10 + 'nent a new nation'
|
72
72
|
third_line = ' ' * 10 + 'e proposition'
|
73
73
|
twenty_fourth_line = ' ' * 10 + 'eople, by the people, for the people'
|
74
|
-
@getty.wrap(70, 10).split("\n")[1].
|
75
|
-
@getty.wrap(70, 10).split("\n")[2].
|
76
|
-
@getty.wrap(70, 10).split("\n")[23].
|
74
|
+
expect(@getty.wrap(70, 10).split("\n")[1]).to match(/^#{second_line}/)
|
75
|
+
expect(@getty.wrap(70, 10).split("\n")[2]).to match(/^#{third_line}/)
|
76
|
+
expect(@getty.wrap(70, 10).split("\n")[23]).to match(/^#{twenty_fourth_line}/)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should be able to quote special TeX characters" do
|
80
|
-
"$10,000".tex_quote.
|
81
|
-
"would~~have".tex_quote.
|
82
|
-
"<hello>".tex_quote.
|
83
|
-
"{hello}".tex_quote.
|
80
|
+
expect("$10,000".tex_quote).to eq("\\$10,000")
|
81
|
+
expect("would~~have".tex_quote).to eq("would\\textasciitilde{}\\textasciitilde{}have")
|
82
|
+
expect("<hello>".tex_quote).to eq("\\textless{}hello\\textgreater{}")
|
83
|
+
expect("{hello}".tex_quote).to eq("\\{hello\\}")
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should be able to fuzzy match with another string" do
|
87
|
-
"Hello, world".fuzzy_match('or').
|
88
|
-
"Hello, world".fuzzy_match('ox').
|
87
|
+
expect("Hello, world".fuzzy_match('or')).to be_truthy
|
88
|
+
expect("Hello, world".fuzzy_match('ox')).to be_falsy
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should be able to fuzzy match with another string containing re" do
|
92
|
-
"Hello, world".matches_with('/or/').
|
93
|
-
"Hello, world".matches_with('/ox/').
|
92
|
+
expect("Hello, world".matches_with('/or/')).to be_truthy
|
93
|
+
expect("Hello, world".matches_with('/ox/')).to be_falsy
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should be able to fuzzy match space-separated parts" do
|
97
|
-
"Hello world".fuzzy_match('hel or').
|
98
|
-
"Hello, world".fuzzy_match('hel ox').
|
97
|
+
expect("Hello world".fuzzy_match('hel or')).to be_truthy
|
98
|
+
expect("Hello, world".fuzzy_match('hel ox')).to be_falsy
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should be able to fuzzy match colon-separated parts" do
|
102
|
-
"Hello:world".fuzzy_match('hel:or').
|
103
|
-
"Hello:world".fuzzy_match('hel:ox').
|
102
|
+
expect("Hello:world".fuzzy_match('hel:or')).to be_truthy
|
103
|
+
expect("Hello:world".fuzzy_match('hel:ox')).to be_falsy
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should be able to fuzzy match colon-separated parts" do
|
107
|
-
"Hello:world".fuzzy_match('hel:or').
|
108
|
-
"Hello:world".fuzzy_match('hel:ox').
|
107
|
+
expect("Hello:world".fuzzy_match('hel:or')).to be_truthy
|
108
|
+
expect("Hello:world".fuzzy_match('hel:ox')).to be_falsy
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should return the matched text" do
|
112
|
-
"Hello:world".fuzzy_match('hel').
|
113
|
-
"Hello:world".fuzzy_match('hel:or').
|
114
|
-
"Hello:world".matches_with('/^h.*r/').
|
112
|
+
expect("Hello:world".fuzzy_match('hel')).to eq('Hel')
|
113
|
+
expect("Hello:world".fuzzy_match('hel:or')).to eq('Hello:wor')
|
114
|
+
expect("Hello:world".matches_with('/^h.*r/')).to eq('Hello:wor')
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should ignore periods, commas, and apostrophes when matching" do
|
118
|
-
"St. Luke's".fuzzy_match('st lukes').
|
119
|
-
"St Lukes".fuzzy_match('st. luke\'s').
|
120
|
-
"St Lukes, Inc.".fuzzy_match('st luke inc').
|
118
|
+
expect("St. Luke's".fuzzy_match('st lukes')).to eq('St Lukes')
|
119
|
+
expect("St Lukes".fuzzy_match('st. luke\'s')).to eq('St Lukes')
|
120
|
+
expect("St Lukes, Inc.".fuzzy_match('st luke inc')).to eq('St Lukes Inc')
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should be able to properly capitalize a string as a title" do
|
data/spec/spec_helper.rb
CHANGED
@@ -11,10 +11,11 @@ require 'byebug'
|
|
11
11
|
#
|
12
12
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
13
13
|
RSpec.configure do |config|
|
14
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
14
|
config.run_all_when_everything_filtered = true
|
16
15
|
config.filter_run :focus
|
17
16
|
|
17
|
+
config.raise_errors_for_deprecations!
|
18
|
+
|
18
19
|
# Run specs in random order to surface order dependencies. If you find an
|
19
20
|
# order dependency and want to debug it, you can fix the order by providing
|
20
21
|
# the seed, which is printed after each run.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel E. Doherty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|