|
19 | 19 |
|
20 | 20 | ConstantSpecs::ContainerA::ChildA::CSL_CONST301 = :const301_5 |
21 | 21 | ConstantSpecs::ContainerA::ChildA.const_source_location(:CSL_CONST301).should == [__FILE__, __LINE__ - 1] |
| 22 | + ensure |
| 23 | + ConstantSpecs::ClassA.send(:remove_const, :CSL_CONST301) |
| 24 | + ConstantSpecs::ModuleA.send(:remove_const, :CSL_CONST301) |
| 25 | + ConstantSpecs::ParentA.send(:remove_const, :CSL_CONST301) |
| 26 | + ConstantSpecs::ContainerA::ChildA.send(:remove_const, :CSL_CONST301) |
22 | 27 | end |
23 | 28 |
|
24 | 29 | it "searches a path in a module included in the immediate class before the superclass" do |
25 | 30 | ConstantSpecs::ParentB::CSL_CONST302 = :const302_1 |
26 | 31 | ConstantSpecs::ModuleF::CSL_CONST302 = :const302_2 |
27 | 32 | ConstantSpecs::ContainerB::ChildB.const_source_location(:CSL_CONST302).should == [__FILE__, __LINE__ - 1] |
| 33 | + ensure |
| 34 | + ConstantSpecs::ParentB.send(:remove_const, :CSL_CONST302) |
| 35 | + ConstantSpecs::ModuleF.send(:remove_const, :CSL_CONST302) |
28 | 36 | end |
29 | 37 |
|
30 | 38 | it "searches a path in the superclass before a module included in the superclass" do |
31 | 39 | ConstantSpecs::ModuleE::CSL_CONST303 = :const303_1 |
32 | 40 | ConstantSpecs::ParentB::CSL_CONST303 = :const303_2 |
33 | 41 | ConstantSpecs::ContainerB::ChildB.const_source_location(:CSL_CONST303).should == [__FILE__, __LINE__ - 1] |
| 42 | + ensure |
| 43 | + ConstantSpecs::ModuleE.send(:remove_const, :CSL_CONST303) |
| 44 | + ConstantSpecs::ParentB.send(:remove_const, :CSL_CONST303) |
34 | 45 | end |
35 | 46 |
|
36 | 47 | it "searches a path in a module included in the superclass" do |
37 | 48 | ConstantSpecs::ModuleA::CSL_CONST304 = :const304_1 |
38 | 49 | ConstantSpecs::ModuleE::CSL_CONST304 = :const304_2 |
39 | 50 | ConstantSpecs::ContainerB::ChildB.const_source_location(:CSL_CONST304).should == [__FILE__, __LINE__ - 1] |
| 51 | + ensure |
| 52 | + ConstantSpecs::ModuleA.send(:remove_const, :CSL_CONST304) |
| 53 | + ConstantSpecs::ModuleE.send(:remove_const, :CSL_CONST304) |
40 | 54 | end |
41 | 55 |
|
42 | 56 | it "searches a path in the superclass chain" do |
43 | 57 | ConstantSpecs::ModuleA::CSL_CONST305 = :const305 |
44 | 58 | ConstantSpecs::ContainerB::ChildB.const_source_location(:CSL_CONST305).should == [__FILE__, __LINE__ - 1] |
| 59 | + ensure |
| 60 | + ConstantSpecs::ModuleA.send(:remove_const, :CSL_CONST305) |
45 | 61 | end |
46 | 62 |
|
47 | 63 | it "returns path to a toplevel constant when the receiver is a Class" do |
48 | 64 | Object::CSL_CONST306 = :const306 |
49 | 65 | ConstantSpecs::ContainerB::ChildB.const_source_location(:CSL_CONST306).should == [__FILE__, __LINE__ - 1] |
| 66 | + ensure |
| 67 | + Object.send(:remove_const, :CSL_CONST306) |
50 | 68 | end |
51 | 69 |
|
52 | 70 | it "returns path to a toplevel constant when the receiver is a Module" do |
53 | 71 | Object::CSL_CONST308 = :const308 |
54 | 72 | ConstantSpecs.const_source_location(:CSL_CONST308).should == [__FILE__, __LINE__ - 1] |
55 | 73 | ConstantSpecs::ModuleA.const_source_location(:CSL_CONST308).should == [__FILE__, __LINE__ - 2] |
| 74 | + ensure |
| 75 | + Object.send(:remove_const, :CSL_CONST308) |
56 | 76 | end |
57 | 77 |
|
58 | 78 | it "returns path to the updated value of a constant" do |
|
63 | 83 | ConstantSpecs::ClassB::CSL_CONST309 = :const309_2 |
64 | 84 | }.should complain(/already initialized constant/) |
65 | 85 | ConstantSpecs::ClassB.const_source_location(:CSL_CONST309).should == [__FILE__, __LINE__ - 2] |
| 86 | + ensure |
| 87 | + ConstantSpecs::ClassB.send(:remove_const, :CSL_CONST309) |
66 | 88 | end |
67 | 89 | end |
68 | 90 |
|
|
0 commit comments