Sha256: ede02efdc4c8609076b7a8401c4bafdd4eb5edca59dbb79ac446153288284abf

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe Launchy do

  before do
    Launchy.reset_global_options
    @stderr  = $stderr
    $stderr = StringIO.new
  end

  after do
    Launchy.reset_global_options
    $stderr = @stderr
  end

  it "logs to stderr when LAUNCHY_DEBUG environment variable is set" do
    ENV["LAUNCHY_DEBUG"] = 'true'
    old_stderr = $stderr
    $stderr = StringIO.new
    Launchy.log "This is a test log message"
    $stderr.string.strip.must_equal "LAUNCHY_DEBUG: This is a test log message"
    $stderr = old_stderr
    ENV["LAUNCHY_DEBUG"] = nil
  end

  it "has the global option :debug" do
    Launchy.extract_global_options( { :debug => 'true' } )
    Launchy.debug?.must_equal true
  end

  it "has the global option :application" do
    Launchy.extract_global_options(  { :application => "wibble" } )
    Launchy.application.must_equal 'wibble'
  end

  it "has the global option :host_os" do
    Launchy.extract_global_options(  { :host_os => "my-special-os-v2" } )
    Launchy.host_os.must_equal 'my-special-os-v2'
  end

  it "has the global option :ruby_engine" do
    Launchy.extract_global_options(  { :ruby_engine => "myruby" } )
    Launchy.ruby_engine.must_equal 'myruby'
  end

  it "prints an error on stderr when no scheme is found for the given uri" do
    Launchy.open( "blah://something/invalid" )
    $stderr.string.must_match( /Failure in opening/ )
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
launchy-2.0.5-java spec/launchy_spec.rb
launchy-2.0.5 spec/launchy_spec.rb
launchy-2.0.4-java spec/launchy_spec.rb
launchy-2.0.4 spec/launchy_spec.rb
launchy-2.0.3-java spec/launchy_spec.rb
launchy-2.0.3 spec/launchy_spec.rb
launchy-2.0.2-java spec/launchy_spec.rb
launchy-2.0.2 spec/launchy_spec.rb