Sha256: d02d81d03868bacf41ae935021ea4a8f884ed216f86c5de1cc7d540f4d0abf11

Contents?: true

Size: 755 Bytes

Versions: 73

Compression:

Stored size: 755 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
        expect(Smoochy.new.sing).to 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
        expect(Rhino.new.sing).to eq("singing")
      end
    end
  end
end

Version data entries

73 entries across 68 versions & 6 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/spec/mongoid/extensions/module_spec.rb
mongoid-7.0.0 spec/mongoid/extensions/module_spec.rb
mongoid-6.4.0 spec/mongoid/extensions/module_spec.rb
mongoid-6.3.0 spec/mongoid/extensions/module_spec.rb
mongoid-6.2.1 spec/mongoid/extensions/module_spec.rb
mongoid-7.0.0.beta spec/mongoid/extensions/module_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/extensions/module_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/extensions/module_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/spec/mongoid/extensions/module_spec.rb
mongoid-6.2.0 spec/mongoid/extensions/module_spec.rb
mongoid-6.1.1 spec/mongoid/extensions/module_spec.rb
mongoid-5.2.1 spec/mongoid/extensions/module_spec.rb
tdiary-5.0.4 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/extensions/module_spec.rb
mongoid-6.1.0 spec/mongoid/extensions/module_spec.rb
mongoid-5.2.0 spec/mongoid/extensions/module_spec.rb
mongoid-5.2.0.rc0 spec/mongoid/extensions/module_spec.rb
mongoid-6.1.0.rc0 spec/mongoid/extensions/module_spec.rb
mongoid-6.0.3 spec/mongoid/extensions/module_spec.rb
mongoid-5.1.6 spec/mongoid/extensions/module_spec.rb
mongoid-6.0.2 spec/mongoid/extensions/module_spec.rb