Sha256: c5a7af6f493e0207e35a4b3685d7868f79ccc15a52f7ba247c9b78b482f817c0

Contents?: true

Size: 1.96 KB

Versions: 8

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

describe Danica::VariablesHolder::Store do 
  let(:default_variables_hash) do
    {
      x: Danica::Wrapper::Variable.new(name: :x),
      y: Danica::Wrapper::Variable.new( latex: '\y' ),
      z: Danica::Wrapper::Number.new(10)
    }
  end
  subject do
    described_class.new(default_variables_hash)
  end

  describe '#variables' do
    context 'when instance has no variables defined' do
      it do
        expect(subject.variables).not_to be_empty
      end

      #it_behaves_like 'an object that returns the default variables'
    end

    context 'when some variables where defined' do
      before do
        subject.containers_hash[:y] = Danica::Wrapper::Number.new(1)
      end

      it 'returns the default variables and the new set one' do
        expect(subject.variables).to eq([
          Danica::Wrapper::Variable.new(name: :x),
          Danica::Wrapper::Number.new(1),
          Danica::Wrapper::Number.new(10)
        ])
      end

      it 'does not change the default variables' do
        expect do
          subject.containers_hash[:x] = Danica::Wrapper::Number.new(2)
        end.not_to change(subject, :default_variables_hash)
      end
    end
  end

  describe '#variables_hash' do
    context 'when instance has no variables defined' do
      #it_behaves_like 'an object that returns the default variables hash'
    end

    context 'when some variables where defined' do
      before do
        subject.containers_hash[:y] = Danica::Wrapper::Number.new(1)
      end

      it 'returns the default hash with the set value' do
        expect(subject.variables_hash).to eq(
          x: Danica::Wrapper::Variable.new(name: :x),
          y: Danica::Wrapper::Number.new(1),
          z: Danica::Wrapper::Number.new(10)
        )
      end
    end
  end

  describe '#containers' do
    it 'is an array of Containers' do
      subject.containers.each do |container|
        expect(container).to be_a(Danica::Wrapper::Container)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
danica-2.7.4 spec/lib/danica/variables_holder/store_spec.rb
danica-2.7.3 spec/lib/danica/variables_holder/store_spec.rb
danica-2.7.2 spec/lib/danica/variables_holder/store_spec.rb
danica-2.7.1 spec/lib/danica/variables_holder/store_spec.rb
danica-2.6.4 spec/lib/danica/variables_holder/store_spec.rb
danica-2.6.3 spec/lib/danica/variables_holder/store_spec.rb
danica-2.6.2 spec/lib/danica/variables_holder/store_spec.rb
danica-2.6.1 spec/lib/danica/variables_holder/store_spec.rb