Sha256: 016b7e4ba42f7c6eec885d4c06a6d402bddd85b9a228546bcc29d222ce9404ca
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' describe ConcernBuilder do class ConcernBuilder::Dummy def initialize @value = 0 end end class ConcernBuilder::Dummy::Builder < ConcernBuilder def init add_method(:blocked) { 1 } add_method(:defined, "@value = @value + #{ options_object.try(:increment) || 1 }") end end let(:options) { {} } let(:dummy_builder) { ConcernBuilder::Dummy::Builder } let(:builder) { dummy_builder.new([], ConcernBuilder::Dummy, options) } let(:instance) { ConcernBuilder::Dummy.new } before do builder.build end context 'when describing a method with block' do it 'creates a method with the block' do expect(instance.blocked).to eq(1) end end context 'when describing a method with string' do it 'creates a method using the string definition' do expect(instance.defined).to eq(1) expect(instance.defined).to eq(2) end end context 'when passing options' do let(:options) { { increment: 2 } } it 'parses the options' do expect(instance.defined).to eq(2) expect(instance.defined).to eq(4) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
concern_builder-0.0.3 | spec/lib/concern_builder_spec.rb |
concern_builder-0.0.2 | spec/lib/concern_builder_spec.rb |
concern_builder-0.0.1 | spec/lib/concern_builder_spec.rb |