diff options
Diffstat (limited to 'spec/ruby/core/kernel/extend_spec.rb')
| -rw-r--r-- | spec/ruby/core/kernel/extend_spec.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/ruby/core/kernel/extend_spec.rb b/spec/ruby/core/kernel/extend_spec.rb index 482eef32e9..a344c7b5ca 100644 --- a/spec/ruby/core/kernel/extend_spec.rb +++ b/spec/ruby/core/kernel/extend_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/classes', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/classes' module KernelSpecs::M def self.extend_object(o) @@ -46,20 +46,20 @@ describe "Kernel#extend" do end it "makes the class a kind_of? the argument" do - class C + c = Class.new do extend KernelSpecs::M end - (C.kind_of? KernelSpecs::M).should == true + (c.kind_of? KernelSpecs::M).should == true end it "raises an ArgumentError when no arguments given" do - lambda { Object.new.extend }.should raise_error(ArgumentError) + -> { Object.new.extend }.should.raise(ArgumentError) end it "raises a TypeError when the argument is not a Module" do o = mock('o') klass = Class.new - lambda { o.extend(klass) }.should raise_error(TypeError) + -> { o.extend(klass) }.should.raise(TypeError) end describe "on frozen instance" do @@ -69,11 +69,23 @@ describe "Kernel#extend" do end it "raises an ArgumentError when no arguments given" do - lambda { @frozen.extend }.should raise_error(ArgumentError) + -> { @frozen.extend }.should.raise(ArgumentError) end - it "raises a RuntimeError" do - lambda { @frozen.extend @module }.should raise_error(RuntimeError) + it "raises a FrozenError" do + -> { @frozen.extend @module }.should.raise(FrozenError) end end + + it "updated class methods of a module when it extends self and includes another module" do + a = Module.new do + extend self + end + b = Module.new do + def foo; :foo; end + end + + a.include b + a.foo.should == :foo + end end |
