cascading_classes 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,58 +36,58 @@ describe "proc properties" do
36
36
  end
37
37
 
38
38
  it "inherits by default" do
39
- @props[:weather][:inherit].must_equal true # sanity
40
- @props[:mood][:inherit].must_equal true
41
- @props[:color][:inherit].must_equal true
39
+ @props[:weather][:inherit].should == true # sanity
40
+ @props[:mood][:inherit].should == true
41
+ @props[:color][:inherit].should == true
42
42
  end
43
43
 
44
44
  describe "a property of type :Proc" do
45
45
  it "evaluates the proc on each invocation of the property" do
46
- A.weather.must_equal :sunny
47
- A.mood.must_equal "content"
48
- A.color.must_equal "rosy"
46
+ A.weather.should == :sunny
47
+ A.mood.should == "content"
48
+ A.color.should == "rosy"
49
49
 
50
50
  A.weather = :rainy
51
- A.mood.must_equal "depressed"
52
- A.color.must_equal "blue"
51
+ A.mood.should == "depressed"
52
+ A.color.should == "blue"
53
53
  end
54
54
 
55
55
  it "has second parameter that is a list of parents" do
56
56
  A.mood = Proc.new{|me, parents| parents}
57
57
 
58
- A.mood.must_equal []
59
- B.mood.must_equal [A]
60
- C.mood.must_equal [B, A]
58
+ A.mood.should == []
59
+ B.mood.should == [A]
60
+ C.mood.should == [B, A]
61
61
 
62
- A.new.mood.must_equal [A]
63
- B.new.mood.must_equal [B, A]
64
- C.new.mood.must_equal [C, B, A]
62
+ A.new.mood.should == [A]
63
+ B.new.mood.should == [B, A]
64
+ C.new.mood.should == [C, B, A]
65
65
  end
66
66
 
67
67
  describe "blank descendents" do
68
68
  it "inherits from its nearest non-blank ancestor" do
69
- B.mood_is_blank?.must_equal true
70
- C.mood_is_blank?.must_equal true
69
+ B.mood_is_blank?.should == true
70
+ C.mood_is_blank?.should == true
71
71
 
72
72
  A.weather = :sunny
73
- B.mood.must_equal "content"
74
- C.mood.must_equal "content"
75
- B.color.must_equal "rosy"
76
- C.color.must_equal "rosy"
73
+ B.mood.should == "content"
74
+ C.mood.should == "content"
75
+ B.color.should == "rosy"
76
+ C.color.should == "rosy"
77
77
 
78
78
  A.weather = :rainy
79
79
 
80
- B.mood.must_equal "depressed"
81
- C.mood.must_equal "depressed"
82
- B.color.must_equal "blue"
83
- C.color.must_equal "blue"
80
+ B.mood.should == "depressed"
81
+ C.mood.should == "depressed"
82
+ B.color.should == "blue"
83
+ C.color.should == "blue"
84
84
  end
85
85
 
86
86
  it "uses its own proc if not blank" do
87
87
  B.mood = Proc.new{ "angry" }
88
88
 
89
- B.mood.must_equal "angry"
90
- B.color.must_equal "blue"
89
+ B.mood.should == "angry"
90
+ B.color.should == "blue"
91
91
  end
92
92
 
93
93
  describe "the parent redefines the proc property" do
@@ -99,9 +99,9 @@ describe "proc properties" do
99
99
  A.weather = :sunny
100
100
  B.weather = :rainy
101
101
 
102
- A.color.must_equal "A: rosy"
103
- B.color.must_equal "B: blue"
104
- C.color.must_equal "C: blue"
102
+ A.color.should == "A: rosy"
103
+ B.color.should == "B: blue"
104
+ C.color.should == "C: blue"
105
105
  end
106
106
  end
107
107
 
@@ -115,46 +115,46 @@ describe "proc properties" do
115
115
  it "inherits the new proc by default" do
116
116
  A.weather = :sunny
117
117
 
118
- A.mood.must_equal "content"
119
- B.mood.must_equal "angry"
120
- C.mood.must_equal "angry"
118
+ A.mood.should == "content"
119
+ B.mood.should == "angry"
120
+ C.mood.should == "angry"
121
121
 
122
- A.color.must_equal "rosy"
123
- B.color.must_equal "B: blue"
124
- C.color.must_equal "C: blue"
122
+ A.color.should == "rosy"
123
+ B.color.should == "B: blue"
124
+ C.color.should == "C: blue"
125
125
  end
126
126
 
127
127
  describe "descendents can any inheritance, using the default instead" do
128
128
  it "accepts ':default' syntax" do
129
129
  A.weather = :sunny
130
130
 
131
- A.mood.must_equal "content"
132
- B.mood.must_equal "angry"
133
- C.mood(:default).must_equal "content"
131
+ A.mood.should == "content"
132
+ B.mood.should == "angry"
133
+ C.mood(:default).should == "content"
134
134
  end
135
135
 
136
136
  it "accepts ':inherit => false' syntax" do
137
137
  A.weather = :sunny
138
138
 
139
- A.mood.must_equal "content"
140
- B.mood.must_equal "angry"
141
- C.mood(:inherit => false).must_equal "content"
139
+ A.mood.should == "content"
140
+ B.mood.should == "angry"
141
+ C.mood(:inherit => false).should == "content"
142
142
 
143
- A.color.must_equal "rosy"
144
- B.color.must_equal "B: blue"
145
- C.color(:inherit => false).must_equal "blue" # ***** take note: C.mood = "depressed" *****
143
+ A.color.should == "rosy"
144
+ B.color.should == "B: blue"
145
+ C.color(:inherit => false).should == "blue" # ***** take note: C.mood = "depressed" *****
146
146
  end
147
147
 
148
148
  it "accepts ':inherit, false' syntax" do
149
149
  A.weather = :sunny
150
150
 
151
- A.mood.must_equal "content"
152
- B.mood.must_equal "angry"
153
- C.mood(:inherit, false).must_equal "content"
151
+ A.mood.should == "content"
152
+ B.mood.should == "angry"
153
+ C.mood(:inherit, false).should == "content"
154
154
 
155
- A.color.must_equal "rosy"
156
- B.color.must_equal "B: blue"
157
- C.color(:inherit, false).must_equal "blue"
155
+ A.color.should == "rosy"
156
+ B.color.should == "B: blue"
157
+ C.color(:inherit, false).should == "blue"
158
158
  end
159
159
  end
160
160
  end
@@ -174,27 +174,27 @@ describe "proc properties" do
174
174
  end
175
175
 
176
176
  it "does not inherit" do
177
- @props[:weather][:inherit].must_equal true # sanity
178
- @props[:mood][:inherit].must_equal false
179
- @props[:color][:inherit].must_equal false
177
+ @props[:weather][:inherit].should == true # sanity
178
+ @props[:mood][:inherit].should == false
179
+ @props[:color][:inherit].should == false
180
180
  end
181
181
 
182
182
  describe "descendents" do
183
183
  it "propogates the initial proc value, but not any descendents' proc" do
184
- B.color_is_blank?.must_equal true
185
- C.mood_is_blank?.must_equal true
184
+ B.color_is_blank?.should == true
185
+ C.mood_is_blank?.should == true
186
186
 
187
- A.weather.must_equal :sunny # sanity
188
- B.weather.must_equal :sunny # sanity
189
- C.weather.must_equal :sunny
187
+ A.weather.should == :sunny # sanity
188
+ B.weather.should == :sunny # sanity
189
+ C.weather.should == :sunny
190
190
 
191
- A.mood.must_equal "content" # sanity
192
- B.mood.must_equal "angry" # sanity
193
- C.mood.must_equal "content"
191
+ A.mood.should == "content" # sanity
192
+ B.mood.should == "angry" # sanity
193
+ C.mood.should == "content"
194
194
 
195
- A.color.must_equal "A: rosy" # sanity
196
- B.color.must_equal "B: blue" # sanity
197
- C.color.must_equal "C: rosy"
195
+ A.color.should == "A: rosy" # sanity
196
+ B.color.should == "B: blue" # sanity
197
+ C.color.should == "C: rosy"
198
198
  end
199
199
  end
200
200
  end
@@ -208,16 +208,16 @@ describe "proc properties" do
208
208
  end
209
209
 
210
210
  it "inherits the property" do
211
- @props[:ingredients][:inherit].must_equal true
212
- @props[:sweet_tooth][:inherit].must_equal true
211
+ @props[:ingredients][:inherit].should == true
212
+ @props[:sweet_tooth][:inherit].should == true
213
213
 
214
- A.ingredients.must_equal Set.new([:sugar, :butter, :flour, :eggs])
215
- B.ingredients.must_equal Set.new([:sugar, :butter, :flour, :eggs])
216
- C.ingredients.must_equal Set.new([:sugar, :butter, :flour, :eggs])
214
+ A.ingredients.should == Set.new([:sugar, :butter, :flour, :eggs])
215
+ B.ingredients.should == Set.new([:sugar, :butter, :flour, :eggs])
216
+ C.ingredients.should == Set.new([:sugar, :butter, :flour, :eggs])
217
217
 
218
- A.sweet_tooth.must_equal false
219
- B.sweet_tooth.must_equal false
220
- C.sweet_tooth.must_equal false
218
+ A.sweet_tooth.should == false
219
+ B.sweet_tooth.should == false
220
+ C.sweet_tooth.should == false
221
221
  end
222
222
 
223
223
  describe "a descendent redefines the property with a proc" do
@@ -244,18 +244,18 @@ describe "proc properties" do
244
244
  C.diabetic = true
245
245
  D.diabetic = false
246
246
 
247
- B.diabetic.must_equal false
248
- C.diabetic.must_equal true
249
- D.diabetic.must_equal false
247
+ B.diabetic.should == false
248
+ C.diabetic.should == true
249
+ D.diabetic.should == false
250
250
 
251
- B.ingredients.must_equal Set.new([:sugar, :butter, :flour, :eggs])
252
- C.ingredients.must_equal Set.new([:splenda, :butter, :flour, :eggs])
253
- D.ingredients.must_equal Set.new([:sugar, :butter, :flour, :eggs])
251
+ B.ingredients.should == Set.new([:sugar, :butter, :flour, :eggs])
252
+ C.ingredients.should == Set.new([:splenda, :butter, :flour, :eggs])
253
+ D.ingredients.should == Set.new([:sugar, :butter, :flour, :eggs])
254
254
 
255
- A.sweet_tooth.must_equal false
256
- B.sweet_tooth.must_equal true
257
- C.sweet_tooth.must_equal false
258
- D.sweet_tooth.must_equal true
255
+ A.sweet_tooth.should == false
256
+ B.sweet_tooth.should == true
257
+ C.sweet_tooth.should == false
258
+ D.sweet_tooth.should == true
259
259
  end
260
260
 
261
261
  describe "descendents redefine the property, but not to a proc" do
@@ -265,11 +265,11 @@ describe "proc properties" do
265
265
  end
266
266
 
267
267
  it "descendents reflect the new 'static' settings" do
268
- C.ingredients.must_equal Set.new([:equal, :butter, :flour, :eggs])
269
- D.ingredients.must_equal Set.new([:equal, :butter, :flour, :eggs])
268
+ C.ingredients.should == Set.new([:equal, :butter, :flour, :eggs])
269
+ D.ingredients.should == Set.new([:equal, :butter, :flour, :eggs])
270
270
 
271
- C.sweet_tooth.must_equal false
272
- D.sweet_tooth.must_equal false
271
+ C.sweet_tooth.should == false
272
+ D.sweet_tooth.should == false
273
273
  end
274
274
  end
275
275
  end
@@ -285,19 +285,19 @@ describe "proc properties" do
285
285
  "green"
286
286
  }
287
287
 
288
- B.color.must_equal("green")
289
- who_am_i.must_equal(B)
290
- which_parents.must_equal([A])
288
+ B.color.should ==("green")
289
+ who_am_i.should ==(B)
290
+ which_parents.should ==([A])
291
291
  end
292
292
 
293
293
  it "evaluates to the property value" do
294
294
  B.color = Proc.new{ "green" }
295
- B.color.must_equal "green"
295
+ B.color.should == "green"
296
296
 
297
297
  C.color = Proc.new{|me, parents|
298
298
  "#{me} #{parents.first.color.capitalize}"
299
299
  }
300
- C.color.must_equal "C Green"
300
+ C.color.should == "C Green"
301
301
  end
302
302
  end
303
303
  end
@@ -333,9 +333,9 @@ describe "examples" do
333
333
  end
334
334
 
335
335
  it "works" do
336
- A.merged_opts.must_equal({:color => "black", :music => ["Rolling Stones"]})
337
- B.merged_opts.must_equal({:color => "black", :music => ["Arcade Fire"]})
338
- C.merged_opts.must_equal({:color => "blond", :music => ["Arcade Fire"]})
336
+ A.merged_opts.should ==({:color => "black", :music => ["Rolling Stones"]})
337
+ B.merged_opts.should ==({:color => "black", :music => ["Arcade Fire"]})
338
+ C.merged_opts.should ==({:color => "blond", :music => ["Arcade Fire"]})
339
339
  end
340
340
  end
341
341
  end
@@ -26,11 +26,11 @@ describe "parents_for()" do
26
26
  end
27
27
 
28
28
  it "lists ancestors for given property" do
29
- A.parents_for(:color).must_equal []
30
- B.parents_for(:color).must_equal [A]
31
- C.parents_for(:color).must_equal [B, A]
29
+ A.parents_for(:color).should == []
30
+ B.parents_for(:color).should == [A]
31
+ C.parents_for(:color).should == [B, A]
32
32
 
33
- B.parents_for(:score).must_equal []
34
- C.parents_for(:score).must_equal [B]
33
+ B.parents_for(:score).should == []
34
+ C.parents_for(:score).should == [B]
35
35
  end
36
36
  end
@@ -33,34 +33,34 @@ describe "custom hash-like class" do
33
33
 
34
34
  describe "by default" do
35
35
  it "is set to not inherit by default" do
36
- @props[:beta][:inherit].must_equal false
36
+ @props[:beta][:inherit].should == false
37
37
  end
38
38
 
39
39
  it "descendents (including instances) do not inherit" do
40
- Parent.new.beta.must_equal MyCustom.new
41
- Child.beta.must_equal MyCustom.new
42
- Child.new.beta.must_equal MyCustom.new
43
- GrandChild.beta.must_equal MyCustom.new
44
- GrandChild.new.beta.must_equal MyCustom.new
40
+ Parent.new.beta.should == MyCustom.new
41
+ Child.beta.should == MyCustom.new
42
+ Child.new.beta.should == MyCustom.new
43
+ GrandChild.beta.should == MyCustom.new
44
+ GrandChild.new.beta.should == MyCustom.new
45
45
  end
46
46
 
47
47
  it "'Parent' has 'default' value" do
48
- Parent.beta.must_equal MyCustom.new(:rank, 4, :color, "red")
48
+ Parent.beta.should == MyCustom.new(:rank, 4, :color, "red")
49
49
  end
50
50
 
51
51
  it "has type ':MyCustom'" do
52
- @props[:beta][:type].must_equal :MyCustom
52
+ @props[:beta][:type].should == :MyCustom
53
53
  end
54
54
 
55
55
  it "has blank value of empty 'MyCustom' object" do
56
56
  mc = MyCustom.new
57
- mc.empty?.must_equal true
57
+ mc.empty?.should == true
58
58
 
59
- @props[:beta][:blank].call(mc).must_equal true
59
+ @props[:beta][:blank].call(mc).should == true
60
60
  end
61
61
 
62
62
  it "has new value of empty 'MyCustom' object" do
63
- @props[:beta][:new].call.must_equal MyCustom.new
63
+ @props[:beta][:new].call.should == MyCustom.new
64
64
  end
65
65
 
66
66
  it "nonblank values never inherit" do
data/spec/helper_spec.rb CHANGED
@@ -7,33 +7,33 @@ require 'minitest/autorun'
7
7
  ## end
8
8
 
9
9
  def blank_inherit_helper(obj, property, expected_depth, expected_val, empty)
10
- obj.send("#{property}_is_blank?").must_equal true
10
+ obj.send("#{property}_is_blank?").should be_true
11
11
 
12
12
  dont_inherit = (expected_depth < 0) ? [0] : (0...expected_depth).to_a
13
13
  dont_inherit << false << nil
14
14
  dont_inherit.each do |i|
15
- obj.send(property, i).must_equal empty
16
- obj.send(property, :inherit => i).must_equal empty
17
- obj.send(property, :inherit, i).must_equal empty
15
+ obj.send(property, i).should == empty
16
+ obj.send(property, :inherit => i).should == empty
17
+ obj.send(property, :inherit, i).should == empty
18
18
  end
19
19
 
20
20
  do_inherit = (expected_depth < 0) ? [] : (expected_depth..(expected_depth+1)).to_a
21
21
  do_inherit << true << -1
22
22
  do_inherit.each do |i|
23
- obj.send(property, i).must_equal(expected_val)
24
- obj.send(property, :inherit => i).must_equal(expected_val)
25
- obj.send(property, :inherit, i).must_equal(expected_val)
23
+ obj.send(property, i).should eq(expected_val)
24
+ obj.send(property, :inherit => i).should eq(expected_val)
25
+ obj.send(property, :inherit, i).should eq(expected_val)
26
26
  end
27
27
  end
28
28
 
29
29
  def nonblank_helper(obj, property, expected)
30
- obj.send("#{property}_is_blank?").must_equal false
30
+ obj.send("#{property}_is_blank?").should be_false
31
31
 
32
32
  vals = [0, 1, 2, 3, -1, false, true, nil]
33
33
  vals.each do |i|
34
- obj.send(property, i).must_equal expected
35
- obj.send(property, :inherit => i).must_equal expected
36
- obj.send(property, :inherit, i).must_equal expected
34
+ obj.send(property, i).should == expected
35
+ obj.send(property, :inherit => i).should == expected
36
+ obj.send(property, :inherit, i).should == expected
37
37
  end
38
38
  end
39
39
 
@@ -9,71 +9,71 @@ end
9
9
  # defaults: hash of defaults
10
10
  def getters(obj, defaults)
11
11
  defaults.each do |key, val|
12
- obj.send(key).must_equal val
12
+ obj.send(key).should == val
13
13
  end
14
14
  end
15
15
 
16
16
  def container_getters(obj, depth)
17
- obj.urls(false).must_equal Array.new
18
- obj.urls(nil).must_equal Array.new
17
+ obj.urls(false).should == Array.new
18
+ obj.urls(nil).should == Array.new
19
19
  0.upto(depth-1).each do |i|
20
- obj.urls(i).must_equal Array.new
20
+ obj.urls(i).should == Array.new
21
21
  end
22
22
  depth.upto(depth+1).each do |i|
23
- obj.urls(i).must_equal ["www.google.com"]
23
+ obj.urls(i).should == ["www.google.com"]
24
24
  end
25
- obj.urls(-1).must_equal ["www.google.com"]
26
- obj.urls(true).must_equal ["www.google.com"]
25
+ obj.urls(-1).should == ["www.google.com"]
26
+ obj.urls(true).should == ["www.google.com"]
27
27
 
28
- obj.name(false).must_equal Hash.new
29
- obj.name(nil).must_equal Hash.new
28
+ obj.name(false).should == Hash.new
29
+ obj.name(nil).should == Hash.new
30
30
  0.upto(depth-1).each do |i|
31
- obj.name(i).must_equal Hash.new
31
+ obj.name(i).should == Hash.new
32
32
  end
33
33
  depth.upto(depth+1).each do |i|
34
- obj.name(i).must_equal({:first => 'jon', :last => 'smith'})
34
+ obj.name(i).should ==({:first => 'jon', :last => 'smith'})
35
35
  end
36
- obj.name(true).must_equal({:first => 'jon', :last => 'smith'})
37
- obj.name(-1).must_equal({:first => 'jon', :last => 'smith'})
36
+ obj.name(true).should ==({:first => 'jon', :last => 'smith'})
37
+ obj.name(-1).should ==({:first => 'jon', :last => 'smith'})
38
38
  end
39
39
 
40
40
  def setters(obj)
41
41
  obj.color = "blue"
42
- obj.color.must_equal "blue"
42
+ obj.color.should == "blue"
43
43
 
44
44
  obj.setting = :rural
45
- obj.setting.must_equal :rural
45
+ obj.setting.should == :rural
46
46
 
47
47
  obj.score = 28.1
48
- obj.score.must_equal 28.1
48
+ obj.score.should == 28.1
49
49
 
50
50
  obj.num = 15
51
- obj.num.must_equal 15
51
+ obj.num.should == 15
52
52
 
53
53
  obj.available = false
54
- obj.available.must_equal false
54
+ obj.available.should == false
55
55
 
56
56
  obj.urls << "www.yahoo.com" << "www.bing.com"
57
- obj.urls.must_equal ["www.yahoo.com", "www.bing.com"]
57
+ obj.urls.should == ["www.yahoo.com", "www.bing.com"]
58
58
 
59
59
  obj.urls = ["www.nytimes.com"]
60
- obj.urls.must_equal ["www.nytimes.com"]
60
+ obj.urls.should == ["www.nytimes.com"]
61
61
 
62
- obj.verify.must_equal false # doesn't inherit name
63
- obj.verify2.must_equal true # inherits name
62
+ obj.verify.should == false # doesn't inherit name
63
+ obj.verify2.should == true # inherits name
64
64
 
65
65
  obj.name[:first] = 'thomas'
66
66
  obj.name[:last] = 'smith'
67
- obj.name.must_equal({:first => 'thomas', :last => 'smith'})
67
+ obj.name.should ==({:first => 'thomas', :last => 'smith'})
68
68
 
69
- obj.verify.must_equal true
70
- obj.verify2.must_equal true
69
+ obj.verify.should == true
70
+ obj.verify2.should == true
71
71
 
72
72
  obj.verify = Proc.new{|me| me.name[:first] !~ /mas/}
73
73
  obj.verify2 = Proc.new{|me| me.name(true)[:first] !~ /mas/}
74
74
 
75
- obj.verify.must_equal false
76
- obj.verify2.must_equal false
75
+ obj.verify.should == false
76
+ obj.verify2.should == false
77
77
  end
78
78
 
79
79
  describe "instances: via 'extend'" do
@@ -107,8 +107,8 @@ describe "instances: via 'extend'" do
107
107
  a = A.new
108
108
  [:color, :setting, :score, :num, :available,
109
109
  :urls, :name, :verify].each do |t|
110
- @props[t][:instances_too].must_equal false
111
- a.respond_to?(:t).must_equal false
110
+ @props[t][:instances_too].should == false
111
+ a.respond_to?(:t).should == false
112
112
  end
113
113
  end
114
114
  end
@@ -132,17 +132,17 @@ describe "instances: via 'extend'" do
132
132
  a = A.new
133
133
  [:color, :setting, :score, :num, :available,
134
134
  :urls, :name, :verify, :verify2].each do |t|
135
- @props[t][:instances_too].must_equal true
136
- a.respond_to?(t).must_equal true
135
+ @props[t][:instances_too].should == true
136
+ a.respond_to?(t).should == true
137
137
  end
138
138
  end
139
139
 
140
140
  it "inherits all non-container properties" do
141
141
  [:color, :setting, :score, :num, :available, :verify, :verify2].each do |t|
142
- @props[t][:inherit].must_equal true
142
+ @props[t][:inherit].should == true
143
143
  end
144
- @props[:urls][:inherit].must_equal false
145
- @props[:name][:inherit].must_equal false
144
+ @props[:urls][:inherit].should == false
145
+ @props[:name][:inherit].should == false
146
146
 
147
147
  defaults = A.to_hash # assumes 'to_hash' works; ie: likely testing it too
148
148
  [:urls, :name, :verify, :verify2].each{|j| defaults.delete j}
@@ -201,17 +201,17 @@ describe "instances: via 'include'" do
201
201
  a = A.new
202
202
  [:color, :setting, :score, :num, :available,
203
203
  :urls, :name, :verify, :verify2].each do |t|
204
- @props[t][:instances_too].must_equal true
205
- a.respond_to?(t).must_equal true
204
+ @props[t][:instances_too].should == true
205
+ a.respond_to?(t).should == true
206
206
  end
207
207
  end
208
208
 
209
209
  it "inherits all non-container properties" do
210
210
  [:color, :setting, :score, :num, :available, :verify, :verify2].each do |t|
211
- @props[t][:inherit].must_equal true
211
+ @props[t][:inherit].should == true
212
212
  end
213
- @props[:urls][:inherit].must_equal false
214
- @props[:name][:inherit].must_equal false
213
+ @props[:urls][:inherit].should == false
214
+ @props[:name][:inherit].should == false
215
215
 
216
216
  defaults = A.to_hash # assumes 'to_hash' works; ie: likely testing it too
217
217
  [:urls, :name, :verify, :verify2].each{|j| defaults.delete j}