File: launchy_test.rb

package info (click to toggle)
ruby-launchy-shim 2.3.0.1%2Bnmu1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 40 kB
  • sloc: ruby: 37; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'minitest/autorun'
require 'launchy'

class LaunchyTest < MiniTest::Test

  def test_calls_xdg_open
    args_used = nil
    system = lambda { |*args| args_used = args.clone }
    Launchy.stub :xdg_open_available, true do
      Launchy.stub :system, system do
        Launchy.open('http://www.debian.org/')
      end
    end

    assert_equal ['xdg-open', 'http://www.debian.org/'], args_used
  end

  def test_warns_if_xdg_open_is_not_available
    explode = lambda { |*args| raise Exception.new("should't call xdg-open if it's not installed") }
    Launchy.stub :xdg_open_available, false do
      Launchy.stub :system, explode do
        Launchy.stub :puts, nil do
          Launchy.open('http://www.debian.org/')
        end
      end
    end
  end

end