Sha256: 9976ae0ee75b2641374f8c72577dd514f1d386916410049223341bf1e445a118
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
require_relative '../lib/eigenclass' RSpec.describe Eigenclass do subject { Object.new.extend(described_class) } it { should delegate_method(:eattr_accessor) .to(:eigenclass) .as(:attr_accessor) } it { should delegate_method(:eattr_reader) .to(:eigenclass) .as(:attr_reader) } it { should delegate_method(:eattr_writer) .to(:eigenclass) .as(:attr_writer) } it { should delegate_method(:edefine_method) .to(:eigenclass) .as(:define_method) } describe '#eigenclass' do it 'should return the eigenclass instance' do expected = class << subject; self end expect(subject.eigenclass).to eq(expected) end end describe '#eigenclass_eval' do it 'should evaluate in the eigenclass scope' do expectation = be_respond_to(:test) expect(subject).not_to expectation subject.eigenclass_eval { attr_reader :test } expect(subject).to expectation expect(subject.class.new).not_to expectation end end describe '#eigenclass_exec' do it 'should evaluate in the eigenclass scope' do expectation = be_respond_to(:test) expect(subject).not_to expectation subject.eigenclass_exec(:test) { |name| attr_reader name } expect(subject).to expectation expect(subject.class.new).not_to expectation end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
eigenclass-2.0.2 | spec/eigenclass_spec.rb |
eigenclass-2.0.1 | spec/eigenclass_spec.rb |
eigenclass-2.0.0 | spec/eigenclass_spec.rb |