Sha256: 11172e45c6f81d9b95eed0a251801efa9241087b24a87f6bc983df0598cb12c8

Contents?: true

Size: 773 Bytes

Versions: 5

Compression:

Stored size: 773 Bytes

Contents

require 'spec_helper'

class PatchTestClass; end
module PatchTestWrapper; end

describe EnsureIt do
  describe '::patch' do
    it 'is private' do
      expect { EnsureIt.patch(PatchTestClass) {} }.to raise_error NoMethodError
    end

    it 'includes methods to object' do
      expect { PatchTestWrapper.obj.test_method }.to raise_error NoMethodError
      EnsureIt.send(:patch, PatchTestClass, &proc do
        def test_method
          'test result'
        end
      end)
      result =
        if ENSURE_IT_REFINED
          PatchTestWrapper.module_eval do
            using EnsureIt
            PatchTestClass.new.test_method
          end
        else
          PatchTestClass.new.test_method
        end
      expect(result).to eq 'test result'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ensure_it-1.0.0 spec/lib/patch_spec.rb
ensure_it-0.1.5 spec/lib/patch_spec.rb
ensure_it-0.1.4 spec/lib/patch_spec.rb
ensure_it-0.1.3 spec/lib/patch_spec.rb
ensure_it-0.1.2 spec/lib/patch_spec.rb