Sha256: 32d1bcda68f7aaf2f85a9e21e525161da64c8a4f85534400089065f9bec9e4db

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'test_helper'

class WebService::SiteTest < Test::Unit::TestCase
  include WebService
  
  def setup
    @site = Site.new("http://example")
  end
  
  def test_url
    assert_equal "http://example", @site.url().to_s
    assert_equal "http://example", @site.url(:prefix => true).to_s
  end
  
  def test_credentials
    site = Site.new("http://example")
    assert_equal nil, site.credentials
    
    site = Site.new("http://foo@example")
    assert_equal ["foo", nil], site.credentials
    
    site = Site.new("http://foo:bar@example")
    assert_equal ["foo", "bar"], site.credentials
  end
  
  def test_url_for
    assert_equal "http://example/foo", @site.url_for("/foo").to_s
    
    @site.expects(:url).with(:public => true).returns URI("http://public")
    assert_equal "http://public/foo", @site.url_for("/foo", :public => true).to_s
  end
  
  def test_root
    assert_equal "http://example/", @site.root.to_s
  end
end

module Rails
  def self.env
    @env ||= Object.new
  end
end

class WebService::Site::SwitchTest < Test::Unit::TestCase
  include WebService
  
  def setup
    @site = Site::Switch.new("http://prod", "http://dev")
  end
  
  def test_url
    env = Rails.env
    
    def env.production?; true end
    assert_equal "http://prod", @site.url.to_s
    
    def env.production?; false end
    assert_equal "http://dev", @site.url.to_s
    assert_equal "http://prod", @site.url(:public => true).to_s
    assert_equal "http://dev", @site.url.to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Roman2K-web-service-0.1.1 test/web_service/site_test.rb