Sha256: 54a7016fe6d9420e7802a576e1686342a79142d44ecfbe985ed070e0f6a6f757

Contents?: true

Size: 1.43 KB

Versions: 32

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Cuboid::OptionGroups::Datastore do
    include_examples 'option_group'
    subject { described_class.new }

    it 'creates attribute accessors on the fly' do
        subject.test = 1
        expect(subject.test).to eq(1)
    end

    describe '#to_h' do
        it 'only includes attributes with accessors' do
            method = :stuff=

            subject.instance_variable_set( :@blah, true )

            value = subject.send( method, 'stuff' )
            expect(subject.to_h).to eq({ method.to_s[0...-1].to_sym => value })
        end
    end

    describe '#update' do
        it 'updates self with the values of the given hash' do
            method = :stuff
            value  = 'stuff'

            subject.update( { method => value } )
            expect(subject.send( method )).to include value
        end

        it 'returns self' do
            expect(subject.update({})).to eq(subject)
        end
    end

    describe '#merge' do
        it 'updates self with the values of the given OptionGroup' do
            method = :stuff
            value  = 'stuff'

            group = described_class.new
            group.update( { method => value } )

            subject.merge( group )
            expect(subject.send( method )).to include value
        end

        it 'returns self' do
            group = described_class.new
            expect(subject.merge( group )).to eq(subject)
        end
    end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cuboid-0.2.11 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.10 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.9 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.8 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.7 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.6 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.5 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.4.2 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.4.1 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.4 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.3 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.2 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2.1 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.2 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.1.9.1 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.1.9 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.1.8 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.1.7 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.1.6.1 spec/cuboid/option_groups/datastore_spec.rb
cuboid-0.1.6 spec/cuboid/option_groups/datastore_spec.rb