Sha256: 28e68750c68654c67bf14154cc68a122c7d7a764476e346e730c9256c72971b4

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 Bytes

Contents

require 'spec_helper'
require 'ruby-debug'

describe "ModuleExtensions" do
  it "should allow a method to be added to a class when the method does not already exists" do
    class A
      my_extension("foo") do
        def foo
          'foo'
        end
      end
    end
    A.instance_methods.include?('foo').should be_true
  end

  it "should not allow adding a method to a class if the method already exists" do
    class A
      def foo
        'bar'
      end
    end

    class A
      my_extension("foo") do
        def foo
          'foo'
        end
      end
    end
    a = A.new
    a.foo.should == 'bar'
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
royw-roys_extensions-0.0.2 spec/module_extensions_spec.rb
royw-roys_extensions-0.0.3 spec/module_extensions_spec.rb