PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Tests/Interop/net/namespaces/modification/addition_spec.rb

#
Ruby | 75 lines | 66 code | 9 blank | 0 comment | 7 complexity | 14af32816a5e051045a208c1683dd8ed MD5 | raw file
 1require File.dirname(__FILE__) + '/../../spec_helper'
 2
 3describe "Adding to .NET namespaces" do
 4  it "is allowed for methods" do
 5    begin
 6      module NotEmptyNamespace
 7        def bar
 8          1
 9        end
10      end
11      
12      class Bar
13        include NotEmptyNamespace
14      end
15
16      Bar.new.bar.should == 1
17    ensure
18      module NotEmptyNamespace
19        undef :bar
20      end
21    end
22  end
23
24  it "is allowed for methods with module_function" do
25    begin
26      module NotEmptyNamespace
27        def bar
28          1
29        end
30        module_function :bar
31      end
32
33      NotEmptyNamespace.bar.should == 1
34    ensure
35      module NotEmptyNamespace
36        class << self
37          undef :bar
38        end
39      end
40    end
41  end
42
43  it "is allowed for Ruby classes" do
44    begin
45      module NotEmptyNamespace
46        class Test; end
47      end
48
49      NotEmptyNamespace::Test.new.should be_kind_of NotEmptyNamespace::Test
50    ensure
51      module NotEmptyNamespace
52        self.send(:remove_const, :Test)
53      end
54    end
55  end
56
57  it "is allowed for ruby modules" do
58    begin
59      module NotEmptyNamespace
60        module Bar
61          def bar
62            1
63          end
64          module_function :bar
65        end
66      end
67
68      NotEmptyNamespace::Bar.bar.should == 1
69    ensure
70      module NotEmptyNamespace
71        self.send(:remove_const, :Bar)
72      end
73    end
74  end
75end