Sha256: d0d1ad8631d0bd2ae0dbfc84f1808af180b476325fce0637dd39de52c3ff5642

Contents?: true

Size: 1.71 KB

Versions: 26

Compression:

Stored size: 1.71 KB

Contents

# encoding: UTF-8

require 'test_helper'
require 'stringex'

class ActsAsUrlConfigurationTest < Test::Unit::TestCase
  def teardown
    Stringex::ActsAsUrl.unconfigure!
  end

  def test_can_set_base_settings
    default_configuration = Stringex::Configuration::ActsAsUrl.new(:url_attribute => "original")
    assert_equal "original", default_configuration.settings.url_attribute

    Stringex::ActsAsUrl.configure do |c|
      c.url_attribute = "special"
    end
    new_configuration = Stringex::Configuration::ActsAsUrl.new
    assert_equal "special", new_configuration.settings.url_attribute
  end

  def test_local_options_overrides_system_wide_configuration
    Stringex::ActsAsUrl.configure do |c|
      c.url_attribute = "special"
    end
    system_configuration = Stringex::Configuration::ActsAsUrl.new
    assert_equal "special", system_configuration.settings.url_attribute

    local_configuration = Stringex::Configuration::ActsAsUrl.new(:url_attribute => "local")
    assert_equal "local", local_configuration.settings.url_attribute
  end

  def test_inherits_settings_from_string_extensions
    string_extensions_settings = Stringex::Configuration::StringExtensions.new
    acts_as_url_settings = Stringex::Configuration::ActsAsUrl.new

    acts_as_url_settings.string_extensions_settings.keys.each do |key|
      assert_equal acts_as_url_settings.settings.send(key), string_extensions_settings.settings.send(key)
    end
  end

  def test_accepts_base_settings_for_string_extensions
    string_extensions_settings = Stringex::Configuration::StringExtensions.new.default_settings

    Stringex::ActsAsUrl.configure do |c|
      string_extensions_settings.keys.each do |key|
        assert_respond_to c, "#{key}="
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
stringex-2.6.1 test/unit/acts_as_url_configuration_test.rb
stringex-2.6.0 test/unit/acts_as_url_configuration_test.rb
stringex-2.5.2 test/unit/acts_as_url_configuration_test.rb
stringex-2.5.1 test/unit/acts_as_url_configuration_test.rb
stringex-2.5.0 test/unit/acts_as_url_configuration_test.rb
stringex-2.4.2 test/unit/acts_as_url_configuration_test.rb
stringex-2.4.1 test/unit/acts_as_url_configuration_test.rb
stringex-2.3.0 test/unit/acts_as_url_configuration_test.rb
stringex-2.2.2 test/unit/acts_as_url_configuration_test.rb
stringex-2.2.1 test/unit/acts_as_url_configuration_test.rb
stringex-2.2.0 test/unit/acts_as_url_configuration_test.rb
stringex-2.1.2 test/unit/acts_as_url_configuration_test.rb
stringex-2.1.1 test/unit/acts_as_url_configuration_test.rb
stringex-2.1.0 test/unit/acts_as_url_configuration_test.rb
stringex-2.0.11 test/unit/acts_as_url_configuration_test.rb
stringex-2.0.10 test/unit/acts_as_url_configuration_test.rb
stringex-2.0.9 test/unit/acts_as_url_configuration_test.rb
stringex-2.0.8 test/unit/acts_as_url_configuration_test.rb
stringex-2.0.7 test/unit/acts_as_url_configuration_test.rb
stringex-2.0.6 test/unit/acts_as_url_configuration_test.rb