Sha256: 5d7cf39fa71071d1218757719f17698d528d1797bb92c4c5c66ef866d837b7f1

Contents?: true

Size: 1.55 KB

Versions: 32

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe Cuboid::State do

    subject { described_class }
    let(:dump_directory) do
        "#{Dir.tmpdir}/state-#{Cuboid::Utilities.generate_token}"
    end

    describe '#application' do
        it "returns an instance of #{described_class::Application}" do
            expect(subject.application).to be_kind_of described_class::Application
        end
    end

    describe '#options' do
        it "returns an instance of #{described_class::Options}" do
            expect(subject.options).to be_kind_of described_class::Options
        end
    end

    describe '#statistics' do
        %w(options application).each do |name|
            it "includes :#{name} statistics" do
                expect(subject.statistics[name.to_sym]).to eq(subject.send(name).statistics)
            end
        end
    end

    describe '.dump' do
        %w(options application).each do |name|
            it "stores ##{name} to disk" do
                previous_instance = subject.send(name)

                subject.dump( dump_directory )

                new_instance = subject.load( dump_directory ).send(name)

                expect(new_instance).to be_kind_of subject.send(name).class
                expect(new_instance.object_id).not_to eq(previous_instance.object_id)
            end
        end
    end

    describe '#clear' do
        %w(options application).each do |method|
            it "clears ##{method}" do
                expect(subject.send(method)).to receive(:clear).at_least(:once)
                subject.clear
            end
        end
    end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cuboid-0.1.5 spec/cuboid/state_spec.rb
cuboid-0.1.4 spec/cuboid/state_spec.rb
cuboid-0.1.3 spec/cuboid/state_spec.rb
cuboid-0.1.2 spec/cuboid/state_spec.rb
cuboid-0.1.1 spec/cuboid/state_spec.rb
cuboid-0.1.0 spec/cuboid/state_spec.rb
cuboid-0.0.5 spec/cuboid/state_spec.rb
cuboid-0.0.4 spec/cuboid/state_spec.rb
cuboid-0.0.3 spec/cuboid/state_spec.rb
cuboid-0.0.3alpha spec/cuboid/state_spec.rb
cuboid-0.0.2alpha spec/cuboid/state_spec.rb
cuboid-0.0.1alpha spec/cuboid/state_spec.rb