Sha256: 74af730b6e4fecf5e948c1e240825c903d3122e90b9c2939d8d49b126f2a0148
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Magicka::Aggregator do subject(:aggregator) { aggregator_class.new(renderer, model) } let(:aggregator_class) { Class.new(described_class) } let(:model) { :my_model } let(:renderer) { instance_double('renderer') } let(:template) { 'templates/forms/input' } let(:locals) { {} } describe '#with_model' do let(:expected_aggregator) do aggregator_class.new(renderer, 'my_model.inner') end it do aggregator.with_model(:inner) do |new_aggregator| expect(new_aggregator).to eq(expected_aggregator) end end end describe '#only' do let(:aggregator_class) do Class.new(described_class) do type :included end end context 'when the type is included in the list' do it 'executes the block' do value = 0 aggregator.only(:not_included, :included, :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 aggregator.only(:not_included, :other) { value += 1 } expect(value).to be_zero end end end describe '#except' do let(:aggregator_class) do Class.new(described_class) do type :included end end context 'when the type is included in the list' do it 'does not execute the block' do value = 0 aggregator.except(:not_included, :included, :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 aggregator.except(:not_included, :other) { value += 1 } expect(value).to eq(1) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
magicka-1.1.0 | spec/lib/magicka/aggregator_spec.rb |