more_core_extensions 1.2.0 → 2.0.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.
@@ -1,5 +1,3 @@
1
- require_relative "../../spec_helper"
2
-
3
1
  describe Array do
4
2
  context '#tableize' do
5
3
  context "on an Array of Arrays" do
@@ -11,7 +9,7 @@ describe Array do
11
9
  Val1 | Val2
12
10
  Value3 | Value4
13
11
  EOF
14
- test.tableize.should == expected
12
+ expect(test.tableize).to eq(expected)
15
13
  end
16
14
 
17
15
  it 'with numeric column values right justified' do
@@ -22,7 +20,7 @@ EOF
22
20
  Val1 | 200
23
21
  Value3 | 30
24
22
  EOF
25
- test.tableize.should == expected
23
+ expect(test.tableize).to eq(expected)
26
24
  end
27
25
 
28
26
  it 'with really long column value' do
@@ -33,7 +31,7 @@ EOF
33
31
  Val1 | Val2
34
32
  Really Really Long Value3 | Value4
35
33
  EOF
36
- test.tableize.should == expected
34
+ expect(test.tableize).to eq(expected)
37
35
  end
38
36
 
39
37
  it 'with really long column value and :max_width option' do
@@ -44,7 +42,7 @@ EOF
44
42
  Val1 | Val2
45
43
  Really Rea | Value4
46
44
  EOF
47
- test.tableize(:max_width => 10).should == expected
45
+ expect(test.tableize(:max_width => 10)).to eq(expected)
48
46
  end
49
47
 
50
48
  it 'with :header => false option' do
@@ -54,7 +52,7 @@ EOF
54
52
  Val1 | Val2
55
53
  Value3 | Value4
56
54
  EOF
57
- test.tableize(:header => false).should == expected
55
+ expect(test.tableize(:header => false)).to eq(expected)
58
56
  end
59
57
  end
60
58
 
@@ -72,8 +70,8 @@ EOF
72
70
  Value4 | Value5 | Value6
73
71
  EOF
74
72
 
75
- @str_case.tableize.should == expected
76
- @sym_case.tableize.should == expected
73
+ expect(@str_case.tableize).to eq(expected)
74
+ expect(@sym_case.tableize).to eq(expected)
77
75
  end
78
76
 
79
77
  context "with :columns option" do
@@ -87,8 +85,8 @@ EOF
87
85
  end
88
86
 
89
87
  it "normal case" do
90
- @str_case.tableize(:columns => ["Col3", "Col1", "Col2"]).should == @expected
91
- @sym_case.tableize(:columns => [:Col3, :Col1, :Col2 ]).should == @expected
88
+ expect(@str_case.tableize(:columns => ["Col3", "Col1", "Col2"])).to eq(@expected)
89
+ expect(@sym_case.tableize(:columns => [:Col3, :Col1, :Col2 ])).to eq(@expected)
92
90
  end
93
91
 
94
92
  it "with only some values" do
@@ -99,18 +97,18 @@ EOF
99
97
  Value6 | Value4
100
98
  EOF
101
99
 
102
- @str_case.tableize(:columns => ["Col3", "Col1"]).should == expected
103
- @sym_case.tableize(:columns => [:Col3, :Col1 ]).should == expected
100
+ expect(@str_case.tableize(:columns => ["Col3", "Col1"])).to eq(expected)
101
+ expect(@sym_case.tableize(:columns => [:Col3, :Col1 ])).to eq(expected)
104
102
  end
105
103
 
106
104
  it "and :leading_columns option" do
107
- @str_case.tableize(:columns => ["Col3", "Col1", "Col2"], :leading_columns => ["Col1"]).should == @expected
108
- @sym_case.tableize(:columns => [:Col3, :Col1, :Col2 ], :leading_columns => [:Col1 ]).should == @expected
105
+ expect(@str_case.tableize(:columns => ["Col3", "Col1", "Col2"], :leading_columns => ["Col1"])).to eq(@expected)
106
+ expect(@sym_case.tableize(:columns => [:Col3, :Col1, :Col2 ], :leading_columns => [:Col1 ])).to eq(@expected)
109
107
  end
110
108
 
111
109
  it "and :trailing_columns option" do
112
- @str_case.tableize(:columns => ["Col3", "Col1", "Col2"], :trailing_columns => ["Col1"]).should == @expected
113
- @sym_case.tableize(:columns => [:Col3, :Col1, :Col2 ], :trailing_columns => [:Col1 ]).should == @expected
110
+ expect(@str_case.tableize(:columns => ["Col3", "Col1", "Col2"], :trailing_columns => ["Col1"])).to eq(@expected)
111
+ expect(@sym_case.tableize(:columns => [:Col3, :Col1, :Col2 ], :trailing_columns => [:Col1 ])).to eq(@expected)
114
112
  end
115
113
  end
116
114
 
@@ -122,8 +120,8 @@ EOF
122
120
  Value6 | Value5 | Value4
123
121
  EOF
124
122
 
125
- @str_case.tableize(:leading_columns => ["Col3", "Col2"]).should == expected
126
- @sym_case.tableize(:leading_columns => [:Col3, :Col2 ]).should == expected
123
+ expect(@str_case.tableize(:leading_columns => ["Col3", "Col2"])).to eq(expected)
124
+ expect(@sym_case.tableize(:leading_columns => [:Col3, :Col2 ])).to eq(expected)
127
125
  end
128
126
 
129
127
  it "with :trailing_columns option" do
@@ -134,8 +132,8 @@ EOF
134
132
  Value4 | Value6 | Value5
135
133
  EOF
136
134
 
137
- @str_case.tableize(:trailing_columns => ["Col3", "Col2"]).should == expected
138
- @sym_case.tableize(:trailing_columns => [:Col3, :Col2 ]).should == expected
135
+ expect(@str_case.tableize(:trailing_columns => ["Col3", "Col2"])).to eq(expected)
136
+ expect(@sym_case.tableize(:trailing_columns => [:Col3, :Col2 ])).to eq(expected)
139
137
  end
140
138
 
141
139
  it "with both :leading_columns and :trailing_columns options" do
@@ -146,13 +144,13 @@ EOF
146
144
  Value6 | Value4 | Value5
147
145
  EOF
148
146
 
149
- @str_case.tableize(:leading_columns => ["Col3"], :trailing_columns => ["Col2"]).should == expected
150
- @sym_case.tableize(:leading_columns => [:Col3 ], :trailing_columns => [:Col2 ]).should == expected
147
+ expect(@str_case.tableize(:leading_columns => ["Col3"], :trailing_columns => ["Col2"])).to eq(expected)
148
+ expect(@sym_case.tableize(:leading_columns => [:Col3 ], :trailing_columns => [:Col2 ])).to eq(expected)
151
149
  end
152
150
  end
153
151
 
154
152
  it 'with an invalid receiver' do
155
- lambda { [1, 2, 3].tableize }.should raise_error(RuntimeError)
153
+ expect { [1, 2, 3].tableize }.to raise_error(RuntimeError)
156
154
  end
157
155
  end
158
- end
156
+ end
@@ -1,17 +1,15 @@
1
- require_relative "../../spec_helper"
2
-
3
1
  describe Hash do
4
2
  it "#delete_nils" do
5
- {}.delete_nils.should == {}
6
- {:a => 1}.delete_nils.should == {:a => 1}
7
- {:c => nil}.delete_nils.should == {}
8
- {:a => 1, :b => [], :c => nil}.delete_nils.should == {:a => 1, :b => []}
3
+ expect({}.delete_nils).to eq({})
4
+ expect({:a => 1}.delete_nils).to eq({:a => 1})
5
+ expect({:c => nil}.delete_nils).to eq({})
6
+ expect({:a => 1, :b => [], :c => nil}.delete_nils).to eq({:a => 1, :b => []})
9
7
  end
10
8
 
11
9
  it "#delete_blanks" do
12
- {}.delete_blanks.should == {}
13
- {:a => 1}.delete_blanks.should == {:a => 1}
14
- {:c => nil}.delete_blanks.should == {}
15
- {:a => 1, :b => [], :c => nil}.delete_blanks.should == {:a => 1}
10
+ expect({}.delete_blanks).to eq({})
11
+ expect({:a => 1}.delete_blanks).to eq({:a => 1})
12
+ expect({:c => nil}.delete_blanks).to eq({})
13
+ expect({:a => 1, :b => [], :c => nil}.delete_blanks).to eq({:a => 1})
16
14
  end
17
15
  end
@@ -1,5 +1,3 @@
1
- require_relative "../../spec_helper"
2
-
3
1
  shared_examples_for "core_ext/hash/nested will not modify arguments" do |meth|
4
2
  it "will not modify arguments" do
5
3
  args = (meth == :store_path ? [1] : [])
@@ -7,49 +5,49 @@ shared_examples_for "core_ext/hash/nested will not modify arguments" do |meth|
7
5
  key = ["d", "d1", "d2", "d3"]
8
6
  key2 = key.dup
9
7
  hash.send(meth, key2, *args)
10
- key2.should == key
8
+ expect(key2).to eq(key)
11
9
 
12
10
  key = ["e", "e1", "e2"]
13
11
  key2 = key.dup
14
12
  hash.send(meth, key2, *args)
15
- key2.should == key
13
+ expect(key2).to eq(key)
16
14
  end
17
15
  end
18
16
 
19
17
  shared_examples_for "core_ext/hash/nested" do
20
18
  context '#fetch_path' do
21
19
  it "with various values" do
22
- hash.fetch_path("a").should == 1
23
- hash.fetch_path("b").should == {}
24
- hash.fetch_path("b", "b1").should be_nil
25
- hash.fetch_path("b", "b1", "b2").should be_nil
26
- hash.fetch_path("c").should == {"c1" => 2}
27
- hash.fetch_path("c", "c1").should == 2
28
- hash.fetch_path("c", "c1", "c2").should be_nil
29
- hash.fetch_path("d", "d1", "d2", "d3").should == 3
30
- hash.fetch_path("d", "d1", "d2", "dx").should be_nil
31
- hash.fetch_path("d", "d1", "d2", "d3", "d4").should be_nil
32
- hash.fetch_path("e").should == {}
33
- hash.fetch_path("e", "e1").should == 4
34
- hash.fetch_path("e", "e1", "e2").should be_nil
35
- hash.fetch_path("f").should == {}
36
- hash.fetch_path("f", "f1").should == {}
37
- hash.fetch_path("f", "f1", "f2").should be_nil
20
+ expect(hash.fetch_path("a")).to eq(1)
21
+ expect(hash.fetch_path("b")).to eq({})
22
+ expect(hash.fetch_path("b", "b1")).to be_nil
23
+ expect(hash.fetch_path("b", "b1", "b2")).to be_nil
24
+ expect(hash.fetch_path("c")).to eq({"c1" => 2})
25
+ expect(hash.fetch_path("c", "c1")).to eq(2)
26
+ expect(hash.fetch_path("c", "c1", "c2")).to be_nil
27
+ expect(hash.fetch_path("d", "d1", "d2", "d3")).to eq(3)
28
+ expect(hash.fetch_path("d", "d1", "d2", "dx")).to be_nil
29
+ expect(hash.fetch_path("d", "d1", "d2", "d3", "d4")).to be_nil
30
+ expect(hash.fetch_path("e")).to eq({})
31
+ expect(hash.fetch_path("e", "e1")).to eq(4)
32
+ expect(hash.fetch_path("e", "e1", "e2")).to be_nil
33
+ expect(hash.fetch_path("f")).to eq({})
34
+ expect(hash.fetch_path("f", "f1")).to eq({})
35
+ expect(hash.fetch_path("f", "f1", "f2")).to be_nil
38
36
  end
39
37
 
40
38
  it "with a nil value" do
41
- hash.fetch_path(nil).should == {nil => 7}
42
- hash.fetch_path("d", nil, "d1").should be_nil
43
- hash.fetch_path("e", nil).should == 4
44
- hash.fetch_path("e", nil, "e1").should be_nil
39
+ expect(hash.fetch_path(nil)).to eq({nil => 7})
40
+ expect(hash.fetch_path("d", nil, "d1")).to be_nil
41
+ expect(hash.fetch_path("e", nil)).to eq(4)
42
+ expect(hash.fetch_path("e", nil, "e1")).to be_nil
45
43
  end
46
44
 
47
45
  it "with array key" do
48
- hash.fetch_path([["h", "i"]]).should == 8
46
+ expect(hash.fetch_path([["h", "i"]])).to eq(8)
49
47
  end
50
48
 
51
49
  it "with invalid values" do
52
- lambda { hash.fetch_path }.should raise_error(ArgumentError)
50
+ expect { hash.fetch_path }.to raise_error(ArgumentError)
53
51
  end
54
52
 
55
53
  include_examples "core_ext/hash/nested will not modify arguments", :fetch_path
@@ -59,54 +57,54 @@ shared_examples_for "core_ext/hash/nested" do
59
57
  it "on an empty hash" do
60
58
  h = described_class.new
61
59
  h.store_path("a", 1)
62
- h.should == {"a" => 1}
60
+ expect(h).to eq({"a" => 1})
63
61
 
64
62
  h = described_class.new
65
63
  h.store_path("b", "b1", 2)
66
- h.should == {"b" => {"b1" => 2}}
64
+ expect(h).to eq({"b" => {"b1" => 2}})
67
65
  end
68
66
 
69
67
  it "on an existing hash" do
70
68
  hash.store_path("b", "b1", 2)
71
- hash["b"].should == {"b1" => 2}
69
+ expect(hash["b"]).to eq({"b1" => 2})
72
70
  hash.store_path("c", "c1", 3)
73
- hash["c"].should == {"c1" => 3}
71
+ expect(hash["c"]).to eq({"c1" => 3})
74
72
  end
75
73
 
76
74
  it "on an existing item that is not a hash" do
77
75
  hash.store_path("a", 2)
78
- hash["a"].should == 2
76
+ expect(hash["a"]).to eq(2)
79
77
  hash.store_path("a", "a1", 3)
80
- hash["a"].should == {"a1" => 3}
78
+ expect(hash["a"]).to eq({"a1" => 3})
81
79
  end
82
80
 
83
81
  it "with an array key" do
84
82
  h = described_class.new
85
83
  h.store_path([["d", "d1"], ["d2", "d3"]], 3)
86
- h.should == {["d", "d1"] => {["d2", "d3"] => 3}}
84
+ expect(h).to eq({["d", "d1"] => {["d2", "d3"] => 3}})
87
85
  end
88
86
 
89
87
  it "with a nil value" do
90
88
  h = described_class.new
91
89
  h.store_path("a", "b", nil)
92
- h.should == {"a" => {"b" => nil}}
90
+ expect(h).to eq({"a" => {"b" => nil}})
93
91
  end
94
92
 
95
93
  it "with an Array value" do
96
94
  h = described_class.new
97
95
  h.store_path("a", "b", ["c", "d"])
98
- h.should == {"a" => {"b" => ["c", "d"]}}
96
+ expect(h).to eq({"a" => {"b" => ["c", "d"]}})
99
97
  end
100
98
 
101
99
  it "with a Hash value" do
102
100
  h = described_class.new
103
101
  h.store_path("a", "b", {"c" => "d"})
104
- h.should == {"a" => {"b" => {"c" => "d"}}}
102
+ expect(h).to eq({"a" => {"b" => {"c" => "d"}}})
105
103
  end
106
104
 
107
105
  it "with invalid values" do
108
- lambda { described_class.new.store_path }.should raise_error(ArgumentError)
109
- lambda { described_class.new.store_path(1) }.should raise_error(ArgumentError)
106
+ expect { described_class.new.store_path }.to raise_error(ArgumentError)
107
+ expect { described_class.new.store_path(1) }.to raise_error(ArgumentError)
110
108
  end
111
109
 
112
110
  include_examples "core_ext/hash/nested will not modify arguments", :store_path
@@ -114,33 +112,33 @@ shared_examples_for "core_ext/hash/nested" do
114
112
 
115
113
  context '#has_key_path?' do
116
114
  it "with various values" do
117
- hash.has_key_path?("a").should be_true
118
- hash.has_key_path?("b").should be_true
119
- hash.has_key_path?("b", "b1").should be_false
120
- hash.has_key_path?("b", "b1", "b2").should be_false
121
- hash.has_key_path?("c").should be_true
122
- hash.has_key_path?("c", "c1").should be_true
123
- hash.has_key_path?("c", "c1", "c2").should be_false
124
- hash.has_key_path?("d", "d1", "d2", "d3").should be_true
125
- hash.has_key_path?("d", "d1", "d2", "dx").should be_false
126
- hash.has_key_path?("d", "d1", "d2", "d3", "d4").should be_false
127
- hash.has_key_path?("e").should be_true
128
- hash.has_key_path?("e", "e1").should be_false
129
- hash.has_key_path?("e", "e1", "e2").should be_false
130
- hash.has_key_path?("f").should be_true
131
- hash.has_key_path?("f", "f1").should be_false
132
- hash.has_key_path?("f", "f1", "f2").should be_false
115
+ expect(hash.has_key_path?("a")).to be_truthy
116
+ expect(hash.has_key_path?("b")).to be_truthy
117
+ expect(hash.has_key_path?("b", "b1")).to be_falsey
118
+ expect(hash.has_key_path?("b", "b1", "b2")).to be_falsey
119
+ expect(hash.has_key_path?("c")).to be_truthy
120
+ expect(hash.has_key_path?("c", "c1")).to be_truthy
121
+ expect(hash.has_key_path?("c", "c1", "c2")).to be_falsey
122
+ expect(hash.has_key_path?("d", "d1", "d2", "d3")).to be_truthy
123
+ expect(hash.has_key_path?("d", "d1", "d2", "dx")).to be_falsey
124
+ expect(hash.has_key_path?("d", "d1", "d2", "d3", "d4")).to be_falsey
125
+ expect(hash.has_key_path?("e")).to be_truthy
126
+ expect(hash.has_key_path?("e", "e1")).to be_falsey
127
+ expect(hash.has_key_path?("e", "e1", "e2")).to be_falsey
128
+ expect(hash.has_key_path?("f")).to be_truthy
129
+ expect(hash.has_key_path?("f", "f1")).to be_falsey
130
+ expect(hash.has_key_path?("f", "f1", "f2")).to be_falsey
133
131
  end
134
132
 
135
133
  it "with a nil value" do
136
- hash.has_key_path?(nil).should be_true
137
- hash.has_key_path?("d", nil, "d1").should be_false
138
- hash.has_key_path?("e", nil).should be_false
139
- hash.has_key_path?("e", nil, "e1").should be_false
134
+ expect(hash.has_key_path?(nil)).to be_truthy
135
+ expect(hash.has_key_path?("d", nil, "d1")).to be_falsey
136
+ expect(hash.has_key_path?("e", nil)).to be_falsey
137
+ expect(hash.has_key_path?("e", nil, "e1")).to be_falsey
140
138
  end
141
139
 
142
140
  it "with invalid values" do
143
- lambda { hash.has_key_path? }.should raise_error(ArgumentError)
141
+ expect { hash.has_key_path? }.to raise_error(ArgumentError)
144
142
  end
145
143
 
146
144
  include_examples "core_ext/hash/nested will not modify arguments", :has_key_path?
@@ -149,28 +147,28 @@ shared_examples_for "core_ext/hash/nested" do
149
147
  context "#delete_path" do
150
148
  it "on a nested hash" do
151
149
  hash.delete_path("d", "d1", "d2", "d3")
152
- hash["d"].should == {"d1"=>{"d2"=>{}}}
150
+ expect(hash["d"]).to eq({"d1"=>{"d2"=>{}}})
153
151
  end
154
152
 
155
153
  it "with an invalid path" do
156
154
  hash.delete_path("d", "d1", :d)
157
- hash["d"].should == {"d1"=>{"d2"=>{"d3"=>3}}}
155
+ expect(hash["d"]).to eq({"d1"=>{"d2"=>{"d3"=>3}}})
158
156
  end
159
157
 
160
158
  include_examples "core_ext/hash/nested will not modify arguments", :delete_path
161
159
  end
162
160
 
163
161
  it "#delete_blank_paths" do
164
- hash.delete_blank_paths.should == {"a"=>1, "c"=>{"c1"=>2}, "d"=>{"d1"=>{"d2"=>{"d3"=>3}}}, nil=>{nil=>7}, ["h", "i"]=>8}
162
+ expect(hash.delete_blank_paths).to eq({"a"=>1, "c"=>{"c1"=>2}, "d"=>{"d1"=>{"d2"=>{"d3"=>3}}}, nil=>{nil=>7}, ["h", "i"]=>8})
165
163
  end
166
164
 
167
165
  context "#find_path" do
168
166
  it "with a real value" do
169
- hash.find_path(3).should == ["d", "d1", "d2", "d3"]
167
+ expect(hash.find_path(3)).to eq(["d", "d1", "d2", "d3"])
170
168
  end
171
169
 
172
170
  it "with non-existent value" do
173
- hash.find_path(42).should == []
171
+ expect(hash.find_path(42)).to eq([])
174
172
  end
175
173
  end
176
174
  end
@@ -192,6 +190,7 @@ describe Hash do
192
190
  include_examples "core_ext/hash/nested"
193
191
  end
194
192
 
193
+ require 'active_support'
195
194
  require 'active_support/core_ext/hash'
196
195
  describe HashWithIndifferentAccess do
197
196
  let(:hash) do
@@ -1,5 +1,3 @@
1
- require "spec_helper"
2
-
3
1
  describe Class do
4
2
  before do
5
3
  module Aaa
@@ -14,33 +12,19 @@ describe Class do
14
12
 
15
13
  context "in_namespace?" do
16
14
  it "Class in Module" do
17
- Aaa::Bbb::Ccc::Ddd.in_namespace?(Aaa::Bbb).should be_true
15
+ expect(Aaa::Bbb::Ccc::Ddd.in_namespace?(Aaa::Bbb)).to be_truthy
18
16
  end
19
17
 
20
18
  it "Module in Module" do
21
- Aaa::Bbb::Ccc::Eee.in_namespace?("Aaa::Bbb").should be_true
19
+ expect(Aaa::Bbb::Ccc::Eee.in_namespace?("Aaa::Bbb")).to be_truthy
22
20
  end
23
21
 
24
22
  it "Instance of Class" do
25
- Aaa::Bbb::Ccc::Ddd.new.in_namespace?(Aaa::Bbb).should be_true
23
+ expect(Aaa::Bbb::Ccc::Ddd.new.in_namespace?(Aaa::Bbb)).to be_truthy
26
24
  end
27
25
 
28
26
  it "Not in namespace" do
29
- Aaa::Bbb::Ccc::Eee.in_namespace?(Aaa::Bbb::Ccc::Ddd).should be_false
30
- end
31
- end
32
-
33
- context "namespace" do
34
- it "Class in Module" do
35
- expect(Aaa::Bbb::Ccc::Ddd.namespace).to eq(["Aaa", "Bbb", "Ccc", "Ddd"])
36
- end
37
-
38
- it "Module in Module" do
39
- expect(Aaa::Bbb::Ccc::Eee.namespace).to eq(["Aaa", "Bbb", "Ccc", "Eee"])
40
- end
41
-
42
- it "Instance of a Class" do
43
- expect(Aaa::Bbb::Ccc::Ddd.new.namespace).to eq(["Aaa", "Bbb", "Ccc", "Ddd"])
27
+ expect(Aaa::Bbb::Ccc::Eee.in_namespace?(Aaa::Bbb::Ccc::Ddd)).to be_falsey
44
28
  end
45
29
  end
46
30
  end
@@ -1,76 +1,74 @@
1
- require_relative "../../spec_helper"
2
-
3
1
  describe String do
4
2
  it '#email?' do
5
- "john@example.com".should be_email
6
- "john.doe@example.com".should be_email
3
+ expect("john@example.com").to be_email
4
+ expect("john.doe@example.com").to be_email
7
5
 
8
- "john.doe@examplecom".should_not be_email
9
- "john.doe@example-com".should_not be_email
10
- "".should_not be_email
11
- "foo".should_not be_email
6
+ expect("john.doe@examplecom").not_to be_email
7
+ expect("john.doe@example-com").not_to be_email
8
+ expect("").not_to be_email
9
+ expect("foo").not_to be_email
12
10
  end
13
11
 
14
12
  it '#domain_name?' do
15
- "example.com".should be_domain_name
13
+ expect("example.com").to be_domain_name
16
14
 
17
- "example..com".should_not be_domain_name
18
- "john.doe@example.com".should_not be_domain_name
19
- "".should_not be_domain_name
20
- "foo".should_not be_domain_name
15
+ expect("example..com").not_to be_domain_name
16
+ expect("john.doe@example.com").not_to be_domain_name
17
+ expect("").not_to be_domain_name
18
+ expect("foo").not_to be_domain_name
21
19
  end
22
20
 
23
21
  it '#ipv4?' do
24
- "192.168.252.15".should be_ipv4
22
+ expect("192.168.252.15").to be_ipv4
25
23
 
26
- "392.168.252.15".should_not be_ipv4
27
- "".should_not be_ipv4
28
- "foo".should_not be_ipv4
29
- "::1".should_not be_ipv4 # 127.0.0.1 in IPv6
30
- "1762:0:0:0:0:B03:1:AF18".should_not be_ipv4 # Standard Notation
31
- "1762:0:0:0:0:B03:127.32.67.15".should_not be_ipv4 # Mixed Notation
32
- "1762::B03:1:AF18".should_not be_ipv4 # Compressed Notation
24
+ expect("392.168.252.15").not_to be_ipv4
25
+ expect("").not_to be_ipv4
26
+ expect("foo").not_to be_ipv4
27
+ expect("::1").not_to be_ipv4 # 127.0.0.1 in IPv6
28
+ expect("1762:0:0:0:0:B03:1:AF18").not_to be_ipv4 # Standard Notation
29
+ expect("1762:0:0:0:0:B03:127.32.67.15").not_to be_ipv4 # Mixed Notation
30
+ expect("1762::B03:1:AF18").not_to be_ipv4 # Compressed Notation
33
31
  end
34
32
 
35
33
  it '#ipv6?' do
36
- "::1".should be_ipv6 # 127.0.0.1 in IPv6
37
- "1762:0:0:0:0:B03:1:AF18".should be_ipv6 # Standard Notation
38
- "1762:0:0:0:0:B03:127.32.67.15".should be_ipv6 # Mixed Notation
39
- "1762::B03:1:AF18".should be_ipv6 # Compressed Notation
34
+ expect("::1").to be_ipv6 # 127.0.0.1 in IPv6
35
+ expect("1762:0:0:0:0:B03:1:AF18").to be_ipv6 # Standard Notation
36
+ expect("1762:0:0:0:0:B03:127.32.67.15").to be_ipv6 # Mixed Notation
37
+ expect("1762::B03:1:AF18").to be_ipv6 # Compressed Notation
40
38
 
41
- "192.168.252.15".should_not be_ipv6
42
- "392.168.252.15".should_not be_ipv6
43
- "".should_not be_ipv6
44
- "foo".should_not be_ipv6
39
+ expect("192.168.252.15").not_to be_ipv6
40
+ expect("392.168.252.15").not_to be_ipv6
41
+ expect("").not_to be_ipv6
42
+ expect("foo").not_to be_ipv6
45
43
  end
46
44
 
47
45
  it "#ipaddress?" do
48
- "192.168.252.15".should be_ipaddress
49
- "::1".should be_ipaddress # 127.0.0.1 in IPv6
50
- "1762:0:0:0:0:B03:1:AF18".should be_ipaddress # Standard Notation
51
- "1762:0:0:0:0:B03:127.32.67.15".should be_ipaddress # Mixed Notation
52
- "1762::B03:1:AF18".should be_ipaddress # Compressed Notation
46
+ expect("192.168.252.15").to be_ipaddress
47
+ expect("::1").to be_ipaddress # 127.0.0.1 in IPv6
48
+ expect("1762:0:0:0:0:B03:1:AF18").to be_ipaddress # Standard Notation
49
+ expect("1762:0:0:0:0:B03:127.32.67.15").to be_ipaddress # Mixed Notation
50
+ expect("1762::B03:1:AF18").to be_ipaddress # Compressed Notation
53
51
 
54
- "392.168.252.15".should_not be_ipaddress
55
- "".should_not be_ipaddress
56
- "foo".should_not be_ipaddress
52
+ expect("392.168.252.15").not_to be_ipaddress
53
+ expect("").not_to be_ipaddress
54
+ expect("foo").not_to be_ipaddress
57
55
  end
58
56
 
59
57
  it "#integer?" do
60
- "100".should be_integer
61
- "-100".should be_integer
58
+ expect("100").to be_integer
59
+ expect("-100").to be_integer
62
60
 
63
- "".should_not be_integer
64
- "100.2".should_not be_integer
65
- "A".should_not be_integer
66
- "100A".should_not be_integer
61
+ expect("").not_to be_integer
62
+ expect("100.2").not_to be_integer
63
+ expect("A").not_to be_integer
64
+ expect("100A").not_to be_integer
67
65
  end
68
66
 
69
67
  it '#guid?' do
70
- '01234567-89ab-cdef-abcd-ef0123456789'.should be_guid
68
+ expect('01234567-89ab-cdef-abcd-ef0123456789').to be_guid
71
69
 
72
- '012ZZZ67-89ab-cdef-abcd-ef0123456789'.should_not be_guid
73
- "".should_not be_guid
74
- "foo".should_not be_guid
70
+ expect('012ZZZ67-89ab-cdef-abcd-ef0123456789').not_to be_guid
71
+ expect("").not_to be_guid
72
+ expect("foo").not_to be_guid
75
73
  end
76
- end
74
+ end