Sha256: d00415da919748e861f1249141c17d8ec685f7c7d017fda95b05b6df308915b6

Contents?: true

Size: 834 Bytes

Versions: 5

Compression:

Stored size: 834 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe Module do
  describe "#deprecate" do
    it "creates a method that calls another method with a deprecation warning" do
      klass = Class.new do
        def car
          :beep
        end
        deprecate :horse, :car
      end
      obj = klass.new
      mock(obj).warn("horse is deprecated. Use car instead.")
      obj.horse.should == :beep
    end

    it "proxies arguments to the new method" do
      klass = Class.new do
        def car(name, location='here')
          "You have a #{name} located at #{location}"
        end
        deprecate :horse, :car
      end
      obj = klass.new
      mock(obj).warn("horse is deprecated. Use car instead.")
      obj.horse('mustang').should == "You have a mustang located at here"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
polonium-0.2.2 spec/polonium/extensions/module_spec.rb
polonium-0.1.0 spec/polonium/extensions/module_spec.rb
polonium-0.1.1 spec/polonium/extensions/module_spec.rb
polonium-0.2.0 spec/polonium/extensions/module_spec.rb
polonium-0.2.1 spec/polonium/extensions/module_spec.rb