Sha256: 2ac45de065037841b57c26483ace4b500dbdd48d8a1a729244163d0df2945843

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 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 "sets the global option :dry_run to value of LAUNCHY_DRY_RUN environment variable" do
    ENV['LAUNCHY_DRY_RUN'] = 'true'
    Launchy.extract_global_options({})
    Launchy.dry_run?.must_equal 'true'
    ENV['LAUNCHY_DRY_RUN'] = 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

13 entries across 13 versions & 3 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/launchy-2.1.2/spec/launchy_spec.rb
launchy-2.1.2-java spec/launchy_spec.rb
launchy-2.1.2 spec/launchy_spec.rb
launchy-2.1.1-java spec/launchy_spec.rb
launchy-2.1.1 spec/launchy_spec.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/launchy-2.1.0/spec/launchy_spec.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/launchy-2.1.0/spec/launchy_spec.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/launchy-2.1.0/spec/launchy_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/launchy-2.1.0/spec/launchy_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/launchy-2.1.0/spec/launchy_spec.rb
launchy-2.1.0-java spec/launchy_spec.rb
launchy-2.1.0 spec/launchy_spec.rb
wijet-launchy-2.0.6 spec/launchy_spec.rb