Sha256: 3f0ec7769a4b35d6eff2032a82d15a007205a7cb7b4b4c6658fd857be44e47af

Contents?: true

Size: 1.81 KB

Versions: 4

Compression:

Stored size: 1.81 KB

Contents

require 'test/unit'
require 'rubygems'
require 'mocha'

RAILS_ROOT = '.'
require 'vizres'

class BrowserTest < Test::Unit::TestCase
  
  def test_open_on_macos
    Browser.expects(:macos?).returns(true)
    Browser.expects(:system).with("open foo")
    Browser.open("foo")
  end
  
  def test_open_on_windows
    Browser.expects(:macos?).returns(false)
    Browser.expects(:windows?).returns(true)
    Browser.expects(:system).with("'C:\Program Files\Internet Explorer\IEXPLORE.EXE' foo")
    Browser.open("foo")
  end
  
  def test_open_on_windows
    Browser.expects(:macos?).returns(false)
    Browser.expects(:windows?).returns(false)
    Browser.expects(:linux?).returns(true)
    Browser.expects(:system).with("kfmclient openURL foo")
    Browser.open("foo")
  end
  
  def test_open_with_unrecognized_os
    Browser.expects(:macos?).returns(false)
    Browser.expects(:windows?).returns(false)
    Browser.expects(:linux?).returns(false)
    Browser.open("foo")
    flunk "Exception should have been thrown"
  rescue Exception => e
    assert_equal "Unrecognized OS. Browser can't be found.", e.message
  end
  
  def test_host
    Config::CONFIG.expects(:[]).with("host").returns("foo")
    assert_equal "foo", Browser.host
  end
  
  def test_macos?
    Browser.expects(:host).returns("darwin")
    assert Browser.macos?
  end
  
  def test_not_macos?
    Browser.expects(:host).returns("bogus")
    assert !Browser.macos?
  end
  
  def test_windows?
    Browser.expects(:host).returns("mswin")
    assert Browser.windows?
  end
  
  def test_not_windows?
    Browser.expects(:host).returns("bogus")
    assert !Browser.windows?
  end
  
  def test_linux?
    Browser.expects(:host).returns("linux")
    assert Browser.linux?
  end
  
  def test_not_linux?
    Browser.expects(:host).returns("bogus")
    assert !Browser.linux?
  end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
pelargir-vizres-0.5 test/vizres/browser_test.rb
radiant-0.7.2 vendor/plugins/vizres/test/vizres/browser_test.rb
radiant-0.7.0 vendor/plugins/vizres/test/vizres/browser_test.rb
radiant-0.7.1 vendor/plugins/vizres/test/vizres/browser_test.rb