spec/lib/magicka/display_spec.rb in magicka-0.5.6 vs spec/lib/magicka/display_spec.rb in magicka-0.6.0

- old
+ new

@@ -14,10 +14,16 @@ allow(renderer) .to receive(:render) .with(partial: template, locals: locals) end + describe '.type' do + it do + expect(described_class.type).to eq(:display) + end + end + describe '#input' do let(:template) { 'templates/display/text' } let(:field) { :field } let(:label) { 'Label' } let(:placeholder) { 'Value' } @@ -161,9 +167,49 @@ it do form.with_model('sub', base: nil) do |new_form| expect(new_form) .to eq(described_class.new(renderer, 'sub')) end + end + end + end + + describe '#only' do + context 'when the type is included in the list' do + it 'executes the block' do + value = 0 + + form.only(:not_included, :display, :other) { value += 1 } + expect(value).to eq(1) + end + end + + context 'when the type is not included in the list' do + it 'does not execute the block' do + value = 0 + + form.only(:not_included, :other) { value += 1 } + expect(value).to be_zero + end + end + end + + describe '#except' do + context 'when the type is included in the list' do + it 'does not execute the block' do + value = 0 + + form.except(:not_included, :display, :other) { value += 1 } + expect(value).to be_zero + end + end + + context 'when the type is not included in the list' do + it 'executes the block' do + value = 0 + + form.except(:not_included, :other) { value += 1 } + expect(value).to eq(1) end end end end