Sha256: c543a748bd776847cd5ff29a26b47b154420322a35779bcc0ac988527f0a2f7c
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# TODO: without .new, using Method describe 'usage of MetaModule::' do after { remove_const :My, :A } describe 'MModule' do subject { MModule } example 'ok' do # definition class My < subject def initialize name @name = name end used do |at| at.abc @name end module Methods def abc value; @abc = value end end end # sort of usage module A extend RSpec::Matchers expect { extend My.new 1 }.to change { @abc }.from(nil).to 1 end Class.new do extend RSpec::Matchers expect { extend My.new 1 }.to change { @abc }.from(nil).to 1 end Object.new.instance_eval do extend RSpec::Matchers expect { extend My.new 1 }.to change { @abc }.from(nil).to 1 end end end describe 'MModule2' do subject { MModule2 } example :ok do class My < MModule2.new :the_value used do |x| x.abc! the_value end module Methods def abc! value; @abc = value end end end Object.new.extend(My.new 100).instance_eval { @abc }.should == 100 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
meta_module-0.0.1 | spec/example_spec.rb |