Sha256: cbfb8a4ddaa6839daf5ca832a8c18324b7eba891e1838fd985e4b9d530e8d393

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

require "spec_helper"

describe Mongoid::Extensions::Module do

  describe "#re_define_method" do

    context "when the method already exists" do

      class Smoochy
        def sing
          "singing"
        end
      end

      before do
        Smoochy.re_define_method("sing") do
          "singing again"
        end
      end

      it "redefines the existing method" do
        Smoochy.new.sing.should eq("singing again")
      end
    end

    context "when the method does not exist" do

      class Rhino
      end

      before do
        Rhino.re_define_method("sing") do
          "singing"
        end
      end

      it "redefines the existing method" do
        Rhino.new.sing.should eq("singing")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-3.1.7 spec/mongoid/extensions/module_spec.rb
mongoid-3.1.6 spec/mongoid/extensions/module_spec.rb
mongoid-3.1.5 spec/mongoid/extensions/module_spec.rb