Sha256: 5491957f17a6fa2b573f072efceaf82a9dc7543b3efe400d662308d1e9d38399

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Launchy::Detect::NixDesktopEnvironment do

  before do
    Launchy.reset_global_options
  end

  after do
    Launchy.reset_global_options
  end


  { "KDE_FULL_SESSION"         => Launchy::Detect::NixDesktopEnvironment::Kde,
    "GNOME_DESKTOP_SESSION_ID" => Launchy::Detect::NixDesktopEnvironment::Gnome }.each_pair do |k,v|
    it "can detect the desktop environment of a *nix machine using ENV[#{k}]" do
      ENV[k] = "launchy-test"
      nix_env = Launchy::Detect::NixDesktopEnvironment.detect
      nix_env.must_equal( v )
      nix_env.browser.must_equal( v.browser )
      ENV.delete( k )
    end
   end

  it "detects the fluxbox desktop environment" do
    ENV['DESKTOP_SESSION'] = 'fluxbox'
    fluxbox_env = Launchy::Detect::NixDesktopEnvironment.detect
    fluxbox_env.must_equal( Launchy::Detect::NixDesktopEnvironment::Fluxbox )
    fluxbox_env.browser.must_equal( Launchy::Detect::NixDesktopEnvironment::Fluxbox.browser )
    ENV.delete( 'DESKTOP_SESSION' )
  end

  it "returns false for XFCE if xprop is not found" do
    Launchy.host_os = "linux"
    Launchy::Detect::NixDesktopEnvironment::Xfce.is_current_desktop_environment?.must_equal( false )
  end

  it "returns nil if it cannot determine the *nix desktop environment" do
    Launchy.host_os = "linux"
    ENV.delete( "KDE_FULL_SESSION" )
    ENV.delete( "GNOME_DESKTOP_SESSION_ID" )
    Launchy::Detect::NixDesktopEnvironment.detect.must_equal( nil )
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
launchy-2.3.0 spec/detect/nix_desktop_environment_spec.rb
launchy-2.2.0-java spec/detect/nix_desktop_environment_spec.rb
launchy-2.2.0 spec/detect/nix_desktop_environment_spec.rb