launchy 2.5.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Launchy::Detect::RubyEngine do
4
-
5
- before do
6
- Launchy.reset_global_options
7
- end
8
-
9
- after do
10
- Launchy.reset_global_options
11
- end
12
-
13
- %w[ ruby jruby rbx macruby ].each do |ruby|
14
- it "detects the #{ruby} RUBY_ENGINE" do
15
- _(Launchy::Detect::RubyEngine.detect( ruby ).ancestors).must_include Launchy::Detect::RubyEngine
16
- end
17
- end
18
-
19
- it "uses the global ruby_engine overrides" do
20
- ENV['LAUNCHY_RUBY_ENGINE'] = "rbx"
21
- _(Launchy::Detect::RubyEngine.detect).must_equal Launchy::Detect::RubyEngine::Rbx
22
- ENV.delete('LAUNCHY_RUBY_ENGINE')
23
- end
24
-
25
- it "does not find a ruby engine of 'foo'" do
26
- _(lambda { Launchy::Detect::RubyEngine.detect( 'foo' ) }).must_raise Launchy::Detect::RubyEngine::NotFoundError
27
- end
28
-
29
- { 'rbx' => :rbx?,
30
- 'ruby' => :mri?,
31
- 'macruby' => :macruby?,
32
- 'jruby' => :jruby? }.each_pair do |engine, method|
33
- it "#{method} returns true for #{engine} " do
34
- _(Launchy::Detect::RubyEngine.detect( engine ).send( method )).must_equal true
35
- end
36
- end
37
- end
@@ -1,103 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Launchy::Detect::Runner do
5
- before do
6
- Launchy.reset_global_options
7
- @test_url = "http://example.com/?foo=bar&baz=wibble"
8
- end
9
-
10
- after do
11
- Launchy.reset_global_options
12
- end
13
-
14
- it "raises an error when there is an unknown host os" do
15
- Launchy.host_os = "foo"
16
- _(lambda{ Launchy::Detect::Runner.detect }).must_raise Launchy::Detect::HostOsFamily::NotFoundError
17
- end
18
-
19
- it "raises an error when there is an unknown ruby engine" do
20
- Launchy.ruby_engine = "wibble"
21
- _(lambda{ Launchy::Detect::Runner.detect }).must_raise Launchy::Detect::RubyEngine::NotFoundError
22
- end
23
-
24
- it "raises and error when there is no command found" do
25
- runner = Launchy::Detect::Runner.detect
26
- _(lambda{ runner.run( nil, *%w[ arg1 arg2 arg 3] ) }).must_raise Launchy::CommandNotFoundError
27
- end
28
-
29
- # On anything that has fork, use Forkable
30
- %w[ linux darwin cygwin ].each do |host_os|
31
- %w[ ruby rbx macruby ].each do |engine_name|
32
- it "engine '#{engine_name}' on OS '#{host_os}' uses runner Forkable" do
33
- Launchy.host_os = host_os
34
- Launchy.ruby_engine = engine_name
35
- engine = Launchy::Detect::Runner.detect
36
- _(engine).must_be_instance_of Launchy::Detect::Runner::Forkable
37
- end
38
- end
39
- end
40
-
41
-
42
- # Jruby always uses the Jruby runner except on Windows
43
- { 'mingw' => Launchy::Detect::Runner::Windows,
44
- 'linux' => Launchy::Detect::Runner::Jruby,
45
- 'darwin' => Launchy::Detect::Runner::Jruby,
46
- 'cygwin' => Launchy::Detect::Runner::Jruby, }.each_pair do |host_os, runner|
47
- it "engine 'jruby' on OS '#{host_os}' uses runner #{runner.name}" do
48
- Launchy.host_os = host_os
49
- Launchy.ruby_engine = 'jruby'
50
- engine = Launchy::Detect::Runner.detect
51
- _(engine).must_be_instance_of runner
52
- end
53
- end
54
-
55
- # If you are on windows, no matter what engine, you use the windows runner
56
- %w[ ruby rbx jruby macruby ].each do |engine_name|
57
- it "uses a Windows runner when the engine is '#{engine_name}'" do
58
- Launchy.host_os = "mingw"
59
- Launchy.ruby_engine = engine_name
60
- e = Launchy::Detect::Runner.detect
61
- _(e).must_be_instance_of Launchy::Detect::Runner::Windows
62
- end
63
- end
64
-
65
- it "Windows launches use the 'cmd' command" do
66
- win = Launchy::Detect::Runner::Windows.new
67
- cmd = win.dry_run( "not-really", [ "http://example.com" ] )
68
- _(cmd).must_equal 'cmd /c not-really http://example.com'
69
- end
70
-
71
- %w[ & | ( ) < > ^ ].each do |reserved_char|
72
- it "Windows escapes '#{reserved_char}' in urls" do
73
- win = Launchy::Detect::Runner::Windows.new
74
- parts = [ 'http://example.com/?foo=bar', 'baz=wibble' ]
75
- url = parts.join( reserved_char )
76
- output_url = parts.join( "^#{reserved_char}" )
77
-
78
- _(win.all_args( "not-really", [ url ] )).must_equal [ 'cmd', '/c', 'not-really', output_url ]
79
-
80
- cmd = win.dry_run( "not-really", [ url ] )
81
- _(cmd).must_equal "cmd /c not-really #{output_url}"
82
- end
83
- end
84
-
85
- it "Jruby doesnot escapes '&' in urls" do
86
- jruby = Launchy::Detect::Runner::Jruby.new
87
- cmd = jruby.dry_run( "not-really", [ @test_url ])
88
- _(cmd).must_equal 'not-really http://example.com/?foo=bar&baz=wibble'
89
- end
90
-
91
- it "does not escape %38 items in urls" do
92
- l = Launchy::Detect::Runner::Forkable.new
93
- cmd = l.dry_run( "not-really", [ "http://ja.wikipedia.org/wiki/%E3%81%82" ] )
94
- _(cmd).must_equal( 'not-really http://ja.wikipedia.org/wiki/%E3%81%82' )
95
- end
96
-
97
- it "can launch a utf8 url" do
98
- url = "http://ja.wikipedia.org/wiki/あ"
99
- l = Launchy::Detect::Runner::Forkable.new
100
- cmd = l.dry_run( "not-really", [ url ] )
101
- _(cmd).must_equal( "not-really #{url}" )
102
- end
103
- end