Sha256: 9bcb4f6935febb3d46868acbeb8976ab3aa6d57960e9f56b8403a5cec2d0d44f

Contents?: true

Size: 1.25 KB

Versions: 10

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe VestalVersions::Options do
  context 'with explicit configuration' do
    let(:options){ {:dependent => :destroy} }
    let(:prepared_options){ User.prepare_versioned_options(options.dup) }

    before do
      VestalVersions::Version.config.clear
      VestalVersions::Version.config.class_name = 'MyCustomVersion'
    end

    it 'has symbolized keys' do
      User.vestal_versions_options.keys.all?{|k| k.is_a?(Symbol) }
    end

    it 'combines class-level and global configuration options' do
      prepared_options.slice(:dependent, :class_name).should == {
        :dependent  => :destroy,
        :class_name => 'MyCustomVersion'
      }
    end

  end

  context 'default configuration options' do
    subject { User.prepare_versioned_options({}) }

    it 'defaults to "VestalVersions::Version" for :class_name' do
      subject[:class_name].should == 'VestalVersions::Version'
    end

    it 'defaults to :delete_all for :dependent' do
      subject[:dependent].should == :delete_all
    end

    it 'forces the :as option value to :versioned' do
      subject[:as].should == :versioned
    end

    it 'defaults to [VestalVersions::Versions] for :extend' do
      subject[:extend].should == [VestalVersions::Versions]
    end
  end
end

Version data entries

10 entries across 10 versions & 6 rubygems

Version Path
houston-vestal_versions-3.0.0 spec/vestal_versions/options_spec.rb
houston-vestal_versions-2.0.1 spec/vestal_versions/options_spec.rb
houston-vestal_versions-2.0.0 spec/vestal_versions/options_spec.rb
vestal_versions-2.0.0 spec/vestal_versions/options_spec.rb
mil_vestal_versions-1.2.6 spec/vestal_versions/options_spec.rb
geothird_vestal_versions-1.2.5 spec/vestal_versions/options_spec.rb
geothird_vestal_versions-1.2.4 spec/vestal_versions/options_spec.rb
geothird_vestal_versions-1.2.3 spec/vestal_versions/options_spec.rb
set_vestal_versions-1.2.2 spec/vestal_versions/options_spec.rb
razenha-vestal_versions-1.2.2 spec/vestal_versions/options_spec.rb