footing 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -7
- data/Gemfile.lock +21 -17
- data/README.md +4 -0
- data/Rakefile +9 -0
- data/lib/footing/version.rb +1 -1
- metadata +98 -17
- data/test/array_test.rb +0 -63
- data/test/footing_test.rb +0 -44
- data/test/hash_test.rb +0 -48
- data/test/kernel_test.rb +0 -9
- data/test/nil_test.rb +0 -16
- data/test/numeric_test.rb +0 -35
- data/test/schema_statements_test.rb +0 -72
- data/test/string_test.rb +0 -88
- data/test/test_helper.rb +0 -6
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,33 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
footing (0.1.7)
|
5
|
+
|
1
6
|
GEM
|
2
|
-
remote:
|
7
|
+
remote: https://rubygems.org/
|
3
8
|
specs:
|
4
|
-
binding_of_caller (0.
|
5
|
-
|
9
|
+
binding_of_caller (0.7.1)
|
10
|
+
debug_inspector (>= 0.0.1)
|
11
|
+
coderay (1.0.9)
|
12
|
+
debug_inspector (0.0.2)
|
6
13
|
method_source (0.8.1)
|
7
|
-
micro_mock (
|
8
|
-
micro_test (0.3.
|
14
|
+
micro_mock (1.1.0)
|
15
|
+
micro_test (0.3.7)
|
9
16
|
os
|
10
17
|
os (0.9.6)
|
11
|
-
pry (0.9.
|
12
|
-
coderay (~> 1.0.5)
|
13
|
-
method_source (~> 0.8)
|
14
|
-
slop (~> 3.3.1)
|
15
|
-
pry (0.9.10-java)
|
18
|
+
pry (0.9.12)
|
16
19
|
coderay (~> 1.0.5)
|
17
20
|
method_source (~> 0.8)
|
18
|
-
slop (~> 3.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
slop (~> 3.4)
|
22
|
+
pry-stack_explorer (0.4.9)
|
23
|
+
binding_of_caller (>= 0.7)
|
24
|
+
pry (~> 0.9.11)
|
25
|
+
rake (10.0.4)
|
26
|
+
slop (3.4.4)
|
24
27
|
|
25
28
|
PLATFORMS
|
26
|
-
java
|
27
29
|
ruby
|
28
30
|
|
29
31
|
DEPENDENCIES
|
32
|
+
footing!
|
30
33
|
micro_mock
|
31
34
|
micro_test
|
32
35
|
pry
|
33
36
|
pry-stack_explorer
|
37
|
+
rake
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Footing
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/hopsoft/footing.png)](https://travis-ci.org/hopsoft/footing)
|
4
|
+
[![Dependency Status](https://gemnasium.com/hopsoft/footing.png)](https://gemnasium.com/hopsoft/footing)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/hopsoft/footing.png)](https://codeclimate.com/github/hopsoft/footing)
|
6
|
+
|
3
7
|
Footing provides some sanity for monkey patching practices.
|
4
8
|
It's also a utility lib that contains additional functionality for core objects that you might find useful.
|
5
9
|
|
data/Rakefile
ADDED
data/lib/footing/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: footing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,89 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
date: 2013-04-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: micro_test
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: micro_mock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pry-stack_explorer
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: A utility belt lib with sane monkey patching.
|
17
95
|
email:
|
18
96
|
- natehop@gmail.com
|
19
97
|
executables: []
|
@@ -34,16 +112,8 @@ files:
|
|
34
112
|
- Gemfile
|
35
113
|
- Gemfile.lock
|
36
114
|
- LICENSE.txt
|
115
|
+
- Rakefile
|
37
116
|
- README.md
|
38
|
-
- test/array_test.rb
|
39
|
-
- test/footing_test.rb
|
40
|
-
- test/hash_test.rb
|
41
|
-
- test/kernel_test.rb
|
42
|
-
- test/nil_test.rb
|
43
|
-
- test/numeric_test.rb
|
44
|
-
- test/schema_statements_test.rb
|
45
|
-
- test/string_test.rb
|
46
|
-
- test/test_helper.rb
|
47
117
|
homepage: https://github.com/hopsoft/footing
|
48
118
|
licenses:
|
49
119
|
- MIT
|
@@ -68,6 +138,17 @@ rubyforge_project:
|
|
68
138
|
rubygems_version: 1.8.23
|
69
139
|
signing_key:
|
70
140
|
specification_version: 3
|
71
|
-
summary: A utility belt lib.
|
72
|
-
test_files:
|
141
|
+
summary: A utility belt lib with sane monkey patching.
|
142
|
+
test_files:
|
143
|
+
- lib/footing/extensions/array.rb
|
144
|
+
- lib/footing/extensions/hash.rb
|
145
|
+
- lib/footing/extensions/kernel.rb
|
146
|
+
- lib/footing/extensions/nil_class.rb
|
147
|
+
- lib/footing/extensions/numeric.rb
|
148
|
+
- lib/footing/extensions/object.rb
|
149
|
+
- lib/footing/extensions/postgresql_adapter.rb
|
150
|
+
- lib/footing/extensions/schema_statements.rb
|
151
|
+
- lib/footing/extensions/string.rb
|
152
|
+
- lib/footing/version.rb
|
153
|
+
- lib/footing.rb
|
73
154
|
has_rdoc:
|
data/test/array_test.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class ArrayTest < MicroTest::Test
|
4
|
-
|
5
|
-
test ".cast_values!" do
|
6
|
-
list = [
|
7
|
-
"1",
|
8
|
-
"2",
|
9
|
-
"3",
|
10
|
-
"0.1",
|
11
|
-
"0.2",
|
12
|
-
"0.3",
|
13
|
-
"true",
|
14
|
-
"false",
|
15
|
-
[
|
16
|
-
"1",
|
17
|
-
"2",
|
18
|
-
"3",
|
19
|
-
"0.1",
|
20
|
-
"0.2",
|
21
|
-
"0.3",
|
22
|
-
"true",
|
23
|
-
"false"
|
24
|
-
],
|
25
|
-
{
|
26
|
-
:number => "1",
|
27
|
-
:true => "true",
|
28
|
-
:false => "false",
|
29
|
-
:ilist => ["1", "2", "3"],
|
30
|
-
:flist => ["0.1", "0.2", "0.3"]
|
31
|
-
}
|
32
|
-
]
|
33
|
-
expected = [
|
34
|
-
1,
|
35
|
-
2,
|
36
|
-
3,
|
37
|
-
0.1,
|
38
|
-
0.2,
|
39
|
-
0.3,
|
40
|
-
true,
|
41
|
-
false,
|
42
|
-
[
|
43
|
-
1,
|
44
|
-
2,
|
45
|
-
3,
|
46
|
-
0.1,
|
47
|
-
0.2,
|
48
|
-
0.3,
|
49
|
-
true,
|
50
|
-
false
|
51
|
-
],
|
52
|
-
{
|
53
|
-
:number => 1,
|
54
|
-
:true => true,
|
55
|
-
:false => false,
|
56
|
-
:ilist => [1, 2, 3],
|
57
|
-
:flist => [0.1, 0.2, 0.3],
|
58
|
-
}
|
59
|
-
]
|
60
|
-
assert list.cast_values! == expected
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
data/test/footing_test.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class FootingTest < MicroTest::Test
|
4
|
-
|
5
|
-
test "patch a class" do
|
6
|
-
class Foo; end
|
7
|
-
module FooClassPatch
|
8
|
-
def foo
|
9
|
-
:foo
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
Footing.patch! Foo, FooClassPatch
|
14
|
-
o = Foo.new
|
15
|
-
assert o.respond_to? :foo
|
16
|
-
assert o.foo == :foo
|
17
|
-
end
|
18
|
-
|
19
|
-
test "patch an instance" do
|
20
|
-
module FooInstancePatch
|
21
|
-
def foo
|
22
|
-
:foo
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
o = Object.new
|
27
|
-
Footing.patch! o, FooInstancePatch
|
28
|
-
assert o.respond_to? :foo
|
29
|
-
assert o.foo == :foo
|
30
|
-
end
|
31
|
-
|
32
|
-
test "setup util methods" do
|
33
|
-
module FooUtil
|
34
|
-
def foo(arg)
|
35
|
-
"foo#{arg}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
Footing.util! FooUtil
|
40
|
-
assert FooUtil.respond_to? :foo
|
41
|
-
assert FooUtil.foo("bar") == "foobar"
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
data/test/hash_test.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class HashTest < MicroTest::Test
|
4
|
-
|
5
|
-
test ".adjust_values!" do
|
6
|
-
dict = {:a => 1, :b => 2, :c => 3}
|
7
|
-
Footing.patch! dict, Footing::Hash
|
8
|
-
dict.adjust_values! { |v| v.to_s }
|
9
|
-
assert dict == {:a=>"1", :b=>"2", :c=>"3"}
|
10
|
-
end
|
11
|
-
|
12
|
-
test ".cast_values!" do
|
13
|
-
dict = {
|
14
|
-
:integer => "1",
|
15
|
-
:float => "0.1",
|
16
|
-
:true => "true",
|
17
|
-
:false => "false",
|
18
|
-
:ilist => ["1", "2", "3"],
|
19
|
-
:flist => ["0.1", "0.2", "0.3"],
|
20
|
-
:nested => {
|
21
|
-
:number => "1",
|
22
|
-
:true => "true",
|
23
|
-
:false => "false",
|
24
|
-
:ilist => ["1", "2", "3"],
|
25
|
-
:flist => ["0.1", "0.2", "0.3"]
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
expected = {
|
30
|
-
:integer => 1,
|
31
|
-
:float => 0.1,
|
32
|
-
:true => true,
|
33
|
-
:false => false,
|
34
|
-
:ilist => [1, 2, 3],
|
35
|
-
:flist => [0.1, 0.2, 0.3],
|
36
|
-
:nested => {
|
37
|
-
:number => 1,
|
38
|
-
:true => true,
|
39
|
-
:false => false,
|
40
|
-
:ilist => [1, 2, 3],
|
41
|
-
:flist => [0.1, 0.2, 0.3]
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
assert dict.cast_values! == expected
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
data/test/kernel_test.rb
DELETED
data/test/nil_test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class NilTest < MicroTest::Test
|
4
|
-
|
5
|
-
test "[]" do
|
6
|
-
Footing.patch! NilClass, Footing::NilClass
|
7
|
-
assert nil[:foo] == nil
|
8
|
-
end
|
9
|
-
|
10
|
-
test "deeply nested [] on Hash" do
|
11
|
-
Footing.patch! NilClass, Footing::NilClass
|
12
|
-
dict = {}
|
13
|
-
assert dict[:foo][:bar][:baz] == nil
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/test/numeric_test.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class NumericTest < MicroTest::Test
|
4
|
-
Footing.patch! Numeric, Footing::Numeric
|
5
|
-
|
6
|
-
test ".positive" do
|
7
|
-
assert -10.positive == 10
|
8
|
-
end
|
9
|
-
|
10
|
-
test ".negative" do
|
11
|
-
assert 10.negative == -10
|
12
|
-
end
|
13
|
-
|
14
|
-
test ".flip_sign" do
|
15
|
-
assert 10.flip_sign == -10
|
16
|
-
assert -10.flip_sign == 10
|
17
|
-
end
|
18
|
-
|
19
|
-
test ".percent_of" do
|
20
|
-
assert 10.percent_of(100) == 10
|
21
|
-
assert 50.percent_of(100) == 50
|
22
|
-
assert 70.percent_of(100) == 70
|
23
|
-
assert 10.percent_of(1000) == 1
|
24
|
-
assert 100.percent_of(1000) == 10
|
25
|
-
assert 1000.percent_of(1000) == 100
|
26
|
-
end
|
27
|
-
|
28
|
-
test ".round_to" do
|
29
|
-
assert 1.0009.round_to(2) == 1
|
30
|
-
assert 1.066.round_to(2) == 1.07
|
31
|
-
assert 1.867.round_to(2) == 1.87
|
32
|
-
assert 1.789259.round_to(5) == 1.78926
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class SchemaStatementsTest < MicroTest::Test
|
4
|
-
|
5
|
-
before do
|
6
|
-
@precisions = %w(
|
7
|
-
microseconds
|
8
|
-
milliseconds
|
9
|
-
second
|
10
|
-
minute *default
|
11
|
-
hour
|
12
|
-
day
|
13
|
-
week
|
14
|
-
month
|
15
|
-
quarter
|
16
|
-
year
|
17
|
-
decade
|
18
|
-
century
|
19
|
-
millennium
|
20
|
-
)
|
21
|
-
|
22
|
-
@mock = MicroMock.make.new
|
23
|
-
Footing.patch! @mock, Footing::PGSchemaStatements
|
24
|
-
@mock.stub(:quote_table_name) { |name| "\"#{name}\"" }
|
25
|
-
@mock.stub(:quote_column_name) { |name| "\"#{name}\"" }
|
26
|
-
@mock.stub(:execute) { |sql| @sql = sql }
|
27
|
-
@mock.stub(:sql) { @sql }
|
28
|
-
end
|
29
|
-
|
30
|
-
test "create a datetime index with default precision of minute" do
|
31
|
-
@mock.add_datetime_index :foo, :bar
|
32
|
-
assert @mock.sql == "create index index_foo_on_bar_by_minute on \"foo\" (date_trunc('minute', \"bar\"))"
|
33
|
-
end
|
34
|
-
|
35
|
-
test "create datetime index with all precisions" do
|
36
|
-
@precisions.each do |precision|
|
37
|
-
@mock.add_datetime_index :foo, :bar, :precision => precision
|
38
|
-
assert @mock.sql == "create index index_foo_on_bar_by_#{precision} on \"foo\" (date_trunc('#{precision}', \"bar\"))"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
test "remove a datetime index" do
|
43
|
-
@mock.remove_datetime_index :foo, :bar
|
44
|
-
assert @mock.sql == "drop index if exists index_foo_on_bar_by_minute"
|
45
|
-
end
|
46
|
-
|
47
|
-
test "remove a datetime index for all precisions" do
|
48
|
-
@precisions.each do |precision|
|
49
|
-
@mock.remove_datetime_index :foo, :bar, :precision => precision
|
50
|
-
assert @mock.sql == "drop index if exists index_foo_on_bar_by_#{precision}"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
test "add timestamp indexes" do
|
55
|
-
@mock.stub(:execute) { |sql| @sql << sql }
|
56
|
-
@mock.stub(:sql) { @sql }
|
57
|
-
@mock.instance_eval { @sql = [] }
|
58
|
-
@mock.add_timestamp_indexes :foo
|
59
|
-
assert @mock.sql.include? "create index index_foo_on_created_at_by_day on \"foo\" (date_trunc('day', \"created_at\"))"
|
60
|
-
assert @mock.sql.include? "create index index_foo_on_updated_at_by_day on \"foo\" (date_trunc('day', \"updated_at\"))"
|
61
|
-
end
|
62
|
-
|
63
|
-
test "remove timestamp indexes" do
|
64
|
-
@mock.stub(:execute) { |sql| @sql << sql }
|
65
|
-
@mock.stub(:sql) { @sql }
|
66
|
-
@mock.instance_eval { @sql = [] }
|
67
|
-
@mock.remove_timestamp_indexes :foo
|
68
|
-
assert @mock.sql.include? "drop index if exists index_foo_on_created_at_by_day"
|
69
|
-
assert @mock.sql.include? "drop index if exists index_foo_on_updated_at_by_day"
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
data/test/string_test.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class StringTest < MicroTest::Test
|
4
|
-
Footing.util! Footing::String
|
5
|
-
Footing.patch! String, Footing::String
|
6
|
-
|
7
|
-
test "patch a string instance" do
|
8
|
-
s = ""
|
9
|
-
assert s.respond_to? :escape
|
10
|
-
assert s.respond_to? :humanize
|
11
|
-
assert s.respond_to? :titleize
|
12
|
-
assert s.respond_to? :titlecase
|
13
|
-
end
|
14
|
-
|
15
|
-
test ".util!" do
|
16
|
-
assert Footing::String.respond_to? :random
|
17
|
-
assert Footing::String.respond_to? :escape
|
18
|
-
assert Footing::String.respond_to? :humanize
|
19
|
-
assert Footing::String.respond_to? :titleize
|
20
|
-
assert Footing::String.respond_to? :titlecase
|
21
|
-
assert Footing::String.respond_to? :boolean?
|
22
|
-
assert Footing::String.respond_to? :numeric?
|
23
|
-
assert Footing::String.respond_to? :cast
|
24
|
-
end
|
25
|
-
|
26
|
-
test ".random" do
|
27
|
-
key = Footing::String.random(100)
|
28
|
-
assert key.length == 100 # expected length
|
29
|
-
assert (key =~ /\W/).nil? # no non-word chars
|
30
|
-
end
|
31
|
-
|
32
|
-
test ".random with rejected chars" do
|
33
|
-
key = Footing::String.random(100, :upcase => true, :reject => [0, 1, 'I', 'O'])
|
34
|
-
assert key.length == 100 # expected length
|
35
|
-
assert (key =~ /\W/).nil? # no non-word chars
|
36
|
-
assert (key =~ /[a-z]/).nil? # no lowercase chars
|
37
|
-
assert (key =~ /[01IO]/).nil? # skipped rejected chars
|
38
|
-
end
|
39
|
-
|
40
|
-
test ".escape" do
|
41
|
-
assert "foobar".escape("b") == "foo\\bar"
|
42
|
-
end
|
43
|
-
|
44
|
-
test ".titleize" do
|
45
|
-
assert "foobar test".titleize == "Foobar Test"
|
46
|
-
end
|
47
|
-
|
48
|
-
test ".classify" do
|
49
|
-
assert "foo_bar_test".classify == "FooBarTest"
|
50
|
-
assert "foo bar test".classify == "FooBarTest"
|
51
|
-
end
|
52
|
-
|
53
|
-
test ".humanize" do
|
54
|
-
assert "foo_bar".humanize == "Foo bar"
|
55
|
-
end
|
56
|
-
|
57
|
-
test ".numeric? integers" do
|
58
|
-
(0..100).each do |i|
|
59
|
-
s = i.to_s
|
60
|
-
assert s.numeric?
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
test ".numeric? floats" do
|
65
|
-
(0..100).each do |i|
|
66
|
-
s = i.to_f.to_s
|
67
|
-
assert s.numeric?
|
68
|
-
end
|
69
|
-
assert "7843.7897389".numeric?
|
70
|
-
assert !"7843.789.7389".numeric?
|
71
|
-
end
|
72
|
-
|
73
|
-
test ".boolean?" do
|
74
|
-
assert "true".boolean?
|
75
|
-
assert "false".boolean?
|
76
|
-
assert !" true".boolean?
|
77
|
-
assert !"false ".boolean?
|
78
|
-
end
|
79
|
-
|
80
|
-
test ".cast" do
|
81
|
-
assert "1.23".cast == 1.23
|
82
|
-
assert "87843".cast == 87843
|
83
|
-
assert "true".cast == true
|
84
|
-
assert "false".cast == false
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
end
|