Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Foo 
  module Bar

    class ClassInEnclosingModule; end 
    def method_in_enclosing_module; end

    describe "Class and Method defined in enclosing module are accessible, so Examples" do 

      it "does automatically get access to the context of Foo::Bar" do 
        Foo::Bar
      end
      it "does automatically get access to ClassInEnclosingModule" do 
        ClassInEnclosingModule.new
      end
      it "does automatically get access to method_in_enclosing_module" do 
        method_in_enclosing_module
      end

      describe "that live inside a nested group" do 

        it "does automatically get access to the context of Foo::Bar" do 
          Foo::Bar
        end
        it "does automatically get access to ClassInEnclosingModule" do 
          ClassInEnclosingModule.new
        end
        it "does automatically get access to method_in_enclosing_module" do 
          method_in_enclosing_module
        end

      end 

    end

    describe "Method and Class defined in group are not accessible, so examples" do

      class ClassDefinedInGroup; end 
      def method_defined_in_group; end

      it "does  automatically get access to the context of Foo::Bar" do
        Foo::Bar
      end
      it "does not automatically get access to ClassDefinedInGroup" do
        lambda {ClassDefinedInGroup.new}.should raise_error(/uninitialized/)
      end
      it "does not automatically get access to method_defined_in_group" do
        lambda {method_defined_in_group}.should raise_error(/undefined/)
      end

      describe "that live inside a nested group" do
        it "does  automatically get access to the context of Foo::Bar" do
          Foo::Bar
        end
        it "does not automatically get access to ClassDefinedInGroup" do
          lambda {ClassDefinedInGroup.new}.should raise_error(/uninitialized/)
        end
        it "does not automatically get access to method_defined_in_group" do
          lambda {method_defined_in_group}.should raise_error(/undefined/)
        end
      end

    end 
  end 
end