Sha256: f54cf0e7f8dde60f3b875b2805fe13e44de1580d71195ca604eda09054a6f010
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'spec_helper' require 'timeout' module ExampleMod def mod; :mod; end end describe Uninclude do let(:klass) { Class.new do if respond_to_missing?(:singleton_class, true) def singleton_class class << self self end end end end } let(:instance) { klass.new } describe '.uninclude' do it 'should uninclude module' do klass.class_eval { include ExampleMod } expect(instance).to respond_to(:mod) expect(instance.mod).to equal(:mod) expect(klass.ancestors).to include(ExampleMod) klass.class_eval { uninclude ExampleMod } expect(instance).to_not respond_to(:mod) expect(klass.ancestors).to_not include(ExampleMod) end it 'should not infinite loop' do klass.class_eval { uninclude(Module.new) } end end if Module.respond_to?(:prepend) describe '.unprepend' do it 'should unprepend module' do klass.class_eval { prepend ExampleMod } expect(instance).to respond_to(:mod) expect(instance.mod).to equal(:mod) expect(klass.ancestors).to include(ExampleMod) klass.class_eval { unprepend ExampleMod } expect(instance).to_not respond_to(:mod) expect(klass.ancestors).to_not include(ExampleMod) end end end describe '#unextend' do it 'should unextend module' do instance.extend(ExampleMod) expect(instance).to respond_to(:mod) expect(instance.mod).to equal(:mod) expect(instance.singleton_class.ancestors).to include(ExampleMod) instance.unextend(ExampleMod) expect(instance).to_not respond_to(:mod) expect(instance.singleton_class.ancestors).to_not include(ExampleMod) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
uninclude-1.2.0 | spec/uninclude_spec.rb |