cascading_classes 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,103 +0,0 @@
1
- begin
2
- require_relative 'helper_spec'
3
- rescue NameError
4
- require File.expand_path('helper_spec', __FILE__)
5
- end
6
-
7
- describe "when CascadingClasses is included by a class" do
8
-
9
-
10
- # this is the same as:
11
- # class A
12
- # include CascadingClasses
13
- # end
14
- #
15
- # class B < A; end
16
- #
17
- # class C < B; end
18
- #
19
- # a = A.new
20
- # b = B.new
21
- # c = C.new
22
- before do
23
- A = Class.new{include CC}
24
- B = Class.new(A)
25
- C = Class.new(B)
26
- @a, @b, @c = A.new, B.new, C.new
27
- end
28
-
29
- after do
30
- Object.send :remove_const, :A
31
- Object.send :remove_const, :B
32
- Object.send :remove_const, :C
33
- end
34
-
35
- describe "when CascadingClasses is included in a module" do
36
- before do
37
- end
38
-
39
- it "must pass all 'extended' test" do
40
- # how do you run those tests??
41
- file = File.join(File.expand_path(File.dirname(__FILE__)), 'extended_spec.rb')
42
- result = `ruby #{file}`
43
- result.must_match /(0) failures/
44
- result.must_match /(0) errors/
45
- end
46
- end
47
-
48
- describe "when a property is set on a class" do
49
- before do
50
- A.all! :once, :twice # same as A.cascade :once, :twice
51
-
52
- A.once = :thinking
53
- B.twice = :speaking
54
- end
55
-
56
- all "cascading flows from that class downwards to all child classes and child objects" do
57
- # :once
58
- A.once.must_equal :thinking
59
- @a.once.must_equal :thinking
60
- B.once.must_equal :thinking
61
- @b.once.must_equal :thinking
62
- C.once.must_equal :thinking
63
- @c.once.must_equal :thinking
64
-
65
- # :twice
66
- A.twice.must_equal nil
67
- @a.twice.must_equal nil
68
- B.twice.must_equal :speaking
69
- @b.twice.must_equal :speaking
70
- C.twice.must_equal :speaking
71
- @c.twice.must_equal :speaking
72
- end
73
- end
74
-
75
- describe "when a property is set on an object" do
76
- before do
77
- A.all! :table
78
-
79
- @a.table = "a large, rectangular object with spotty marks"
80
- end
81
-
82
- it "only affects that object" do
83
- A.table.must_equal nil
84
- @a.table.must_equal "a large, rectangular object with spotty marks"
85
- B.table.must_equal nil
86
- @b.table.must_equal nil
87
- C.table.must_equal nil
88
- @c.table.must_equal nil
89
- end
90
- end
91
-
92
- describe "when a property is set to false" do
93
- before do
94
- A.cascade [:has_time, false]
95
- end
96
-
97
- it "should return false, not nil" do
98
- A.new.has_time.must_equal false
99
- end
100
- end
101
-
102
-
103
- end