Sha256: 4e4cdc05099f823651b386a4b7c819b99f84b284144cedff5f7ea499eb89782d

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'
require 'uri'
class ConfigTest < Test::Unit::TestCase
  include BillboardApi
  def setup
    @config = Config.instance
    @config.clear!
  end
  should "Return nil on unknown config" do
        assert_equal nil, @config.test_property
      end
      
      should 'return the value upon set operation' do
        assert 'test', (@config.test_property= 'test')
      end
      
  should 'store and return a setting' do
    assert 'test', (@config.test_property= 'test')
    assert 'test', @config.test_property
  end
  
  should 'update an existing property' do
    assert 'bla', (@config.test_property= 'bla')
    assert 'bla', @config.test_property
    assert 'test', (@config.test_property= 'test')
    assert 'test', @config.test_property
  end
  
  
  should 'Allow configuration trough block' do
    Config.configure do |conf|
      conf.foobar= 'http://foo.bar'
    end
    assert_equal 'http://foo.bar', @config.foobar
  end
  
  
  should 'allow override of setting' do
    @config.bla = 12
    assert_equal 13, @config.bla(13)
  end
  
  should 'validate! only if all required settings are present' do
    assert_raises RuntimeError do
      Config.instance.validate!  
    end
    Config.configure do |config|
      config.return_after_payment_url= '1'
      config.paypal_service_url= 2
      config.paypal_notify_url= 3
      config.paypal_receiver_email= 4
      config.site_url = 'http://localhost:3000'
    end
    Config.instance.validate!
  end
  
  should 'set site_url to Tax and Order' do
      Config.instance.site_url = 'http://foo.bar.com'
      assert_equal 'http://foo.bar.com', Order.site.to_s
      assert_equal 'http://foo.bar.com', Tax.site.to_s
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simplificator-billboard-api-0.6.1 test/config_test.rb
simplificator-billboard-api-0.6.2 test/config_test.rb
simplificator-billboard-api-0.7.0 test/config_test.rb
simplificator-billboard-api-0.7.2 test/config_test.rb
simplificator-billboard-api-0.7.1 test/config_test.rb