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