Sha256: 14f2c5f540b2c6e83b952f2bbfc43aa3c9037f5e20d8bb062d057a17884fd404

Contents?: true

Size: 1.5 KB

Versions: 69

Compression:

Stored size: 1.5 KB

Contents

require File.dirname(__FILE__) + '/abstract_unit'

class OptionMergerTest < Test::Unit::TestCase
  def setup
    @options = {:hello => 'world'}
  end

  def test_method_with_options_merges_options_when_options_are_present
    local_options = {:cool => true}

    with_options(@options) do |o|
      assert_equal local_options, method_with_options(local_options)
      assert_equal @options.merge(local_options),
        o.method_with_options(local_options)
    end
  end

  def test_method_with_options_appends_options_when_options_are_missing
    with_options(@options) do |o|
      assert_equal Hash.new, method_with_options
      assert_equal @options, o.method_with_options
    end
  end

  def test_method_with_options_allows_to_overwrite_options
    local_options = {:hello => 'moon'}
    assert_equal @options.keys, local_options.keys

    with_options(@options) do |o|
      assert_equal local_options, method_with_options(local_options)
      assert_equal @options.merge(local_options),
        o.method_with_options(local_options)
      assert_equal local_options, o.method_with_options(local_options)
    end
    with_options(local_options) do |o|
      assert_equal local_options.merge(@options),
        o.method_with_options(@options)
    end
  end

  # Needed when counting objects with the ObjectSpace
  def test_option_merger_class_method
    assert_equal ActiveSupport::OptionMerger, ActiveSupport::OptionMerger.new('', '').class
  end

  private
    def method_with_options(options = {})
      options
    end
end

Version data entries

69 entries across 69 versions & 3 rubygems

Version Path
backlog-0.0.0 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.0.1 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.0.2 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.0.5 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.0.4 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.1.0 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.1.1 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.1.2 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.2.0 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.2.1 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.0 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.1 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.2 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.3 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.4 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.6 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.5 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.7 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.8 vendor/rails/activesupport/test/option_merger_test.rb
backlog-0.3.9 vendor/rails/activesupport/test/option_merger_test.rb