Sha256: 17507550bd233a66055deddaf0843d08191b0fc31f318f1bba0833b2a7da32d7
Contents?: true
Size: 1.68 KB
Versions: 4
Compression:
Stored size: 1.68 KB
Contents
require File.join(File.dirname(__FILE__), 'test_helper') class OptionsTest < Test::Unit::TestCase context 'Configuration options' do setup do @options = {:dependent => :destroy} @configuration = {:class_name => 'MyCustomVersion'} VestalVersions::Configuration.options.clear @configuration.each{|k,v| VestalVersions::Configuration.send("#{k}=", v) } @prepared_options = User.prepare_versioned_options(@options.dup) end should 'have symbolized keys' do assert User.vestal_versions_options.keys.all?{|k| k.is_a?(Symbol) } end should 'combine class-level and global configuration options' do combined_keys = (@options.keys + @configuration.keys).map(&:to_sym).uniq combined_options = @configuration.symbolize_keys.merge(@options.symbolize_keys) assert_equal @prepared_options.slice(*combined_keys), combined_options end teardown do VestalVersions::Configuration.options.clear User.prepare_versioned_options({}) end end context 'Given no options, configuration options' do setup do @prepared_options = User.prepare_versioned_options({}) end should 'default to "VestalVersions::Version" for :class_name' do assert_equal 'VestalVersions::Version', @prepared_options[:class_name] end should 'default to :delete_all for :dependent' do assert_equal :delete_all, @prepared_options[:dependent] end should 'force the :as option value to :versioned' do assert_equal :versioned, @prepared_options[:as] end should 'default to [VestalVersions::Versions] for :extend' do assert_equal [VestalVersions::Versions], @prepared_options[:extend] end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
nickjones-vestal_versions-1.0.3 | test/options_test.rb |
vestal_versions-1.0.2 | test/options_test.rb |
vestal_versions-1.0.1 | test/options_test.rb |
vestal_versions-1.0.0 | test/options_test.rb |