Sha256: c4ce63db2e26734b9c4854bb5db02b23881f79c21ee018a173bd8c4c45cdcd72

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

require 'eymiha/test'
require 'eymiha/url'


class TC_url_opener < Test::Unit::TestCase

  # exception_handler is tested indirectly
  # relative_base is tested in UrlNormalizer
  # method_missing is tested indirectly
  # windows registry access is assumed correct
  
  include Eymiha

  def test_open_apple
    url_opener = UrlOpener.new
    probe UrlOpener, :open_apple do
      assert(url_opener.open_apple("foo") == "open foo")
    end
    url_opener.url_viewer = "url_viewer"
    probe UrlOpener, :open_apple do
      assert(url_opener.open_apple("foo") == "url_viewer foo")
    end
  end

  def test_open_pc
    url_opener = UrlOpener.new
    UrlOpener.windows_browser = "windows_browser"
    probe UrlOpener, :open_pc do
      assert(url_opener.open_pc("foo") == "windows_browser foo")
    end
    url_opener.url_viewer = "url_viewer"
    probe UrlOpener, :open_pc do
      assert(url_opener.open_pc("foo") == "url_viewer foo")
    end
  end

  def test_open_other
    url_opener = UrlOpener.new(self,nil,nil)
    probe UrlOpener, :open_other do
      assert_raise(UrlException) { url_opener.open_foo }
    end
    url_opener.url_viewer = "url_viewer"
    probe UrlOpener, :open_other do
        assert(url_opener.open_other("foo") == "url_viewer foo")
    end
  end
  
end


# just for testing...

class Eymiha::UrlOpener
  
  def system(command)
    command
  end

  def url_normalizer=(url_normalizer)
    @url_normalizer = url_normalizer
  end

  def normalize(url,relative_base)
    url
  end

  def self.windows_browser=(windows_browser)
    @@windows_browser = windows_browser
  end

  def handle
    raise UrlException
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eymiha_url-1.0.0 test/tc_url_opener.rb
eymiha_url-1.0.1 test/tc_url_opener.rb
eymiha_url-1.0.2 test/tc_url_opener.rb