Sha256: 074acf849e0d5a1001556edccda200dd3402a464e95bc9922e01816eabc7a335

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'
require 'mock_application'

class JunkApp < Launchy::Application
  def self.handles?( uri )
    uri.scheme == "junk"
  end
end

describe Launchy::Application do
  it 'registers inherited classes' do
    class Junk2App < Launchy::Application
      def self.handles?( uri )
        uri.scheme == "junk2"
      end
    end
    _(Launchy::Application.children).must_include( Junk2App )
    Launchy::Application.children.delete( Junk2App )
  end

  it "can find an app" do
    _(Launchy::Application.children).must_include( JunkApp )
    _(Launchy::Application.children.size).must_equal 3
    uri = Addressable::URI.parse( "junk:///foo" )
    _(Launchy::Application.handling( uri )).must_equal( JunkApp  )
  end

  it "raises an error if an application cannot be found for the given scheme" do
    uri = Addressable::URI.parse( "foo:///bar" )
    _(lambda { Launchy::Application.handling( uri ) }).must_raise( Launchy::ApplicationNotFoundError )
  end

  it "can find open or curl or xdg-open" do
    found = %w[ open curl xdg-open ].any? do |app|
      Launchy::Application.find_executable( app )
    end
    _(found).must_equal true
  end

  it "does not find xyzzy" do
    _(Launchy::Application.find_executable( "xyzzy" )).must_be_nil
  end
end

Version data entries

24 entries across 15 versions & 2 rubygems

Version Path
launchy-3.0.0 spec/application_spec.rb
launchy-2.5.2 spec/application_spec.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/launchy-2.5.0/spec/application_spec.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/launchy-2.5.0/spec/application_spec.rb