Sha256: 5f949321c47160404b845383a076bcb86d868a7af8c1eb4a89acb43ea3bc1696
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Sinclair::ClassMethods do subject(:builder) { builder_class.new(dummy_class, options) } let(:options) { {} } let(:instance) { dummy_class.new } let(:dummy_class) { Class.new } let(:builder_class) { Sinclair } describe '#build' do let(:block) do method_name = :some_method value = 1 proc do add_method(method_name) { value } end end it 'executes the block and builds' do expect { builder_class.build(dummy_class, options, &block) } .to add_method(:some_method).to(dummy_class) end context 'when the method is built and called' do before do builder_class.build(dummy_class, options, &block) end it 'returns the value' do expect(instance.some_method).to eq(1) end end context 'when no block is given' do let(:builder_class) do Class.new(Sinclair) do def build add_method(:some_method) { 1 } super end end end it 'executes the block and builds' do expect { builder_class.build(dummy_class, options) } .to add_method(:some_method).to(dummy_class) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinclair-2.0.0 | spec/lib/sinclair/class_methods_spec.rb |
sinclair-1.16.3 | spec/lib/sinclair/class_methods_spec.rb |