PageRenderTime 22ms CodeModel.GetById 1ms app.highlight 15ms RepoModel.GetById 2ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Tests/Interop/net/delegate/shared/instantiation.rb

#
Ruby | 31 lines | 24 code | 7 blank | 0 comment | 0 complexity | 60625157653f38e5787afb21d8e3c7cd MD5 | raw file
 1require File.dirname(__FILE__) + "/../fixtures/classes"
 2
 3describe :delegate_instantiation, :shared => true do
 4  before(:each) do
 5    @class = @method
 6  end
 7
 8  it "creates a delegate from bound methods" do
 9    @class.new(DelegateTester.method(:bar)).should be_kind_of @class 
10  end
11
12  it "creates a delegate from lambdas" do
13    @class.new(lambda { puts '123' }).should be_kind_of @class
14  end
15
16  it "creates a delegate from procs" do
17    @class.new(proc { puts '123' }).should be_kind_of @class
18  end
19
20  it "creates a delegate from blocks" do
21    (@class.new {puts '123'}).should be_kind_of @class
22  end
23
24  it "requires an argument" do
25    lambda {@class.new}.should raise_error ArgumentError
26  end
27
28  it "requires a proc-like object" do
29    lambda {@class.new(1)}.should raise_error TypeError
30  end
31end