rush2 0.7.1 → 0.8.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +29 -30
- data/VERSION +1 -1
- data/lib/rush.rb +0 -1
- data/lib/rush/commands.rb +24 -6
- data/lib/rush/shell.rb +22 -18
- data/spec/access_spec.rb +34 -34
- data/spec/array_ext_spec.rb +9 -9
- data/spec/box_spec.rb +72 -72
- data/spec/commands_spec.rb +43 -43
- data/spec/embeddable_shell_spec.rb +4 -4
- data/spec/entry_spec.rb +123 -123
- data/spec/file_spec.rb +79 -79
- data/spec/find_by_spec.rb +9 -9
- data/spec/fixnum_ext_spec.rb +3 -3
- data/spec/local_spec.rb +91 -91
- data/spec/process_set_spec.rb +46 -46
- data/spec/process_spec.rb +58 -56
- data/spec/rush_spec.rb +19 -19
- data/spec/shell_spec.rb +1 -1
- data/spec/ssh_tunnel_spec.rb +122 -122
- metadata +3 -5
- data/lib/rush/remote.rb +0 -33
- data/spec/remote_spec.rb +0 -140
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 138ab89d7e5dde2b93dc3e71009015e705a3121d
|
4
|
+
data.tar.gz: f4d4b23bb5147ab16379cb9b4d70c38915e206d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44baa45dd729f5904cfc775ec161dd81f8627a31769f0a5004b3acc9f650c3747f6c14b8a86064e9e8a5d10a37ac3026618aebea416e4dc2866c7e5c2b0fa461
|
7
|
+
data.tar.gz: 92401d933b62410986da1ac56932a08fb8009c9524b8a493fbc10e7705a103af27833cc76b5e9067b684ad66ed1c1dc07a9cd16c81c5b915c4bed293472b5acf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
4
|
+
addressable (2.3.8)
|
5
5
|
builder (3.2.2)
|
6
6
|
coderay (1.1.0)
|
7
7
|
coolline (0.5.0)
|
@@ -9,19 +9,19 @@ GEM
|
|
9
9
|
descendants_tracker (0.0.4)
|
10
10
|
thread_safe (~> 0.3, >= 0.3.1)
|
11
11
|
diff-lcs (1.2.5)
|
12
|
-
faraday (0.9.
|
12
|
+
faraday (0.9.1)
|
13
13
|
multipart-post (>= 1.2, < 3)
|
14
|
-
git (1.2.
|
15
|
-
github_api (0.12.
|
14
|
+
git (1.2.9.1)
|
15
|
+
github_api (0.12.3)
|
16
16
|
addressable (~> 2.3)
|
17
17
|
descendants_tracker (~> 0.0.4)
|
18
18
|
faraday (~> 0.8, < 0.10)
|
19
|
-
hashie (>= 3.
|
19
|
+
hashie (>= 3.3)
|
20
20
|
multi_json (>= 1.7.5, < 2.0)
|
21
21
|
nokogiri (~> 1.6.3)
|
22
22
|
oauth2
|
23
|
-
hashie (3.
|
24
|
-
highline (1.
|
23
|
+
hashie (3.4.0)
|
24
|
+
highline (1.7.1)
|
25
25
|
jeweler (2.0.1)
|
26
26
|
builder
|
27
27
|
bundler (>= 1.0)
|
@@ -31,16 +31,15 @@ GEM
|
|
31
31
|
nokogiri (>= 1.5.10)
|
32
32
|
rake
|
33
33
|
rdoc
|
34
|
-
|
35
|
-
jwt (1.0.0)
|
34
|
+
jwt (1.4.1)
|
36
35
|
method_source (0.8.2)
|
37
|
-
mini_portile (0.6.
|
38
|
-
multi_json (1.
|
36
|
+
mini_portile (0.6.2)
|
37
|
+
multi_json (1.11.0)
|
39
38
|
multi_xml (0.5.5)
|
40
39
|
multipart-post (2.0.0)
|
41
|
-
net-ssh (2.9.
|
42
|
-
nokogiri (1.6.
|
43
|
-
mini_portile (
|
40
|
+
net-ssh (2.9.2)
|
41
|
+
nokogiri (1.6.6.2)
|
42
|
+
mini_portile (~> 0.6.0)
|
44
43
|
oauth2 (1.0.0)
|
45
44
|
faraday (>= 0.8, < 0.10)
|
46
45
|
jwt (~> 1.0)
|
@@ -51,25 +50,25 @@ GEM
|
|
51
50
|
coderay (~> 1.1.0)
|
52
51
|
method_source (~> 0.8.1)
|
53
52
|
slop (~> 3.4)
|
54
|
-
rack (1.
|
55
|
-
rake (10.
|
56
|
-
rdoc (4.
|
57
|
-
|
58
|
-
|
59
|
-
rspec-
|
60
|
-
rspec-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
rspec-expectations (3.1.2)
|
53
|
+
rack (1.6.0)
|
54
|
+
rake (10.4.2)
|
55
|
+
rdoc (4.2.0)
|
56
|
+
rspec (3.2.0)
|
57
|
+
rspec-core (~> 3.2.0)
|
58
|
+
rspec-expectations (~> 3.2.0)
|
59
|
+
rspec-mocks (~> 3.2.0)
|
60
|
+
rspec-core (3.2.2)
|
61
|
+
rspec-support (~> 3.2.0)
|
62
|
+
rspec-expectations (3.2.0)
|
65
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-mocks (3.1
|
68
|
-
|
69
|
-
|
64
|
+
rspec-support (~> 3.2.0)
|
65
|
+
rspec-mocks (3.2.1)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.2.0)
|
68
|
+
rspec-support (3.2.2)
|
70
69
|
session (3.2.0)
|
71
70
|
slop (3.6.0)
|
72
|
-
thread_safe (0.3.
|
71
|
+
thread_safe (0.3.5)
|
73
72
|
unicode_utils (1.4.0)
|
74
73
|
|
75
74
|
PLATFORMS
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/lib/rush.rb
CHANGED
data/lib/rush/commands.rb
CHANGED
@@ -39,6 +39,12 @@ module Rush::Commands
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
# Open file with $EDITOR.
|
43
|
+
#
|
44
|
+
def edit(*args)
|
45
|
+
open_with ENV['EDITOR'], *args
|
46
|
+
end
|
47
|
+
|
42
48
|
# Invoke vi on one or more files - only works locally.
|
43
49
|
def vi(*args)
|
44
50
|
if self.class == Rush::Dir
|
@@ -64,13 +70,25 @@ module Rush::Commands
|
|
64
70
|
# Open file with any application you like.
|
65
71
|
# Usage:
|
66
72
|
# home.locate('timetable').open_with :vim
|
67
|
-
|
68
|
-
|
69
|
-
system
|
73
|
+
# home['.vimrc'].vim { other: '+55', x: true, u: 'other_vimrc', cmd: 'ls' }
|
74
|
+
def open_with(app, *args, **opts)
|
75
|
+
system open_command(app, *args, opts)
|
70
76
|
end
|
71
77
|
|
72
|
-
def output_of(app, *args)
|
73
|
-
|
74
|
-
|
78
|
+
def output_of(app, *args, **opts)
|
79
|
+
`#{open_command(app, *args, opts)}`
|
80
|
+
end
|
81
|
+
|
82
|
+
def open_command(app, *args, **opts)
|
83
|
+
names = dir? ? '' : entries.map(&:to_s).join(' ')
|
84
|
+
options = opts.map do |k, v|
|
85
|
+
key = k.size == 1 ? "-#{k}" : "--#{k}"
|
86
|
+
case
|
87
|
+
when v == true then key
|
88
|
+
when k == 'other' || k == :other then v
|
89
|
+
else "#{key} #{v}"
|
90
|
+
end
|
91
|
+
end.join(' ')
|
92
|
+
"cd #{dirname}; #{app.to_s} #{names} #{options} #{args.join(' ')}"
|
75
93
|
end
|
76
94
|
end
|
data/lib/rush/shell.rb
CHANGED
@@ -19,6 +19,15 @@ module Rush
|
|
19
19
|
pwd = Rush::Dir.new(ENV['PWD']) if ENV['PWD']
|
20
20
|
|
21
21
|
@config = Rush::Config.new
|
22
|
+
@box = Rush::Box.new
|
23
|
+
@pure_binding = @box.instance_eval 'binding'
|
24
|
+
$last_res = nil
|
25
|
+
load_custom_commands
|
26
|
+
set_readline
|
27
|
+
@multiline_cmd = '' # Multiline commands should be stored somewhere
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_readline
|
22
31
|
@history = Coolline::History.new config.history_file.full_path
|
23
32
|
Coolline::Settings[:word_boundaries] = [' ', "\t"]
|
24
33
|
Coolline::Settings[:completion_word_boundaries] = [' ', "\t"]
|
@@ -26,19 +35,26 @@ module Rush
|
|
26
35
|
c.transform_proc = proc { syntax_highlight c.line }
|
27
36
|
c.completion_proc = proc { complete c.completed_word }
|
28
37
|
end
|
38
|
+
end
|
29
39
|
|
30
|
-
|
31
|
-
@pure_binding = @box.instance_eval 'binding'
|
32
|
-
$last_res = nil
|
33
|
-
|
40
|
+
def load_custom_commands
|
34
41
|
eval config.load_env, @pure_binding
|
35
42
|
commands = config.load_commands
|
36
43
|
Rush::Dir.class_eval commands
|
37
44
|
Rush::File.class_eval commands
|
38
45
|
Array.class_eval commands
|
46
|
+
end
|
39
47
|
|
40
|
-
|
41
|
-
|
48
|
+
# Run the interactive shell using coolline.
|
49
|
+
def run
|
50
|
+
loop do
|
51
|
+
prompt = self.class.prompt || "#{`whoami`.chomp} $ "
|
52
|
+
cmd = @readline.readline prompt
|
53
|
+
finish if cmd.nil? || cmd == 'exit'
|
54
|
+
next if cmd.empty?
|
55
|
+
@history << cmd
|
56
|
+
execute cmd
|
57
|
+
end
|
42
58
|
end
|
43
59
|
|
44
60
|
# Run a single command.
|
@@ -63,18 +79,6 @@ module Rush
|
|
63
79
|
@multiline_cmd = ''
|
64
80
|
end
|
65
81
|
|
66
|
-
# Run the interactive shell using coolline.
|
67
|
-
def run
|
68
|
-
loop do
|
69
|
-
prompt = self.class.prompt || "#{`whoami`.chomp} $ "
|
70
|
-
cmd = @readline.readline prompt
|
71
|
-
finish if cmd.nil? || cmd == 'exit'
|
72
|
-
next if cmd.empty?
|
73
|
-
@history << cmd
|
74
|
-
execute cmd
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
82
|
# Tune the prompt with
|
79
83
|
# Rush::Shell.prompt = 'hey there! > '
|
80
84
|
class << self
|
data/spec/access_spec.rb
CHANGED
@@ -14,55 +14,55 @@ describe Rush::Access do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "gets parts from a one-part symbol like :user" do
|
17
|
-
@access.parts_from(:user).
|
17
|
+
expect(@access.parts_from(:user)).to eq(%w(user))
|
18
18
|
end
|
19
19
|
|
20
20
|
it "gets parts from a two-part symbol like :read_write" do
|
21
|
-
@access.parts_from(:read_write).
|
21
|
+
expect(@access.parts_from(:read_write)).to eq(%w(read write))
|
22
22
|
end
|
23
23
|
|
24
24
|
it "allows use of 'and' in multipart symbols, like :user_and_group" do
|
25
|
-
@access.parts_from(:user_and_group).
|
25
|
+
expect(@access.parts_from(:user_and_group)).to eq( %w(user group))
|
26
26
|
end
|
27
27
|
|
28
28
|
it "extract_list verifies that all the parts among the valid choices" do
|
29
|
-
@access.
|
30
|
-
@access.extract_list('type', :red_green, %w(red blue green)).
|
29
|
+
expect(@access).to receive(:parts_from).with(:red_green).and_return(%w(red green))
|
30
|
+
expect(@access.extract_list('type', :red_green, %w(red blue green))).to eq(%w(red green))
|
31
31
|
end
|
32
32
|
|
33
33
|
it "extract_list raises a BadAccessSpecifier when there is part not in the list of choices" do
|
34
|
-
|
34
|
+
expect do
|
35
35
|
@access.extract_list('role', :user_bork, %w(user group))
|
36
|
-
end.
|
36
|
+
end.to raise_error(Rush::BadAccessSpecifier, "Unrecognized role: bork")
|
37
37
|
end
|
38
38
|
|
39
39
|
it "sets one value in the matrix of permissions and roles" do
|
40
40
|
@access.set_matrix(%w(read), %w(user))
|
41
|
-
@access.user_can_read.
|
41
|
+
expect(@access.user_can_read).to eq(true)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "sets two values in the matrix of permissions and roles" do
|
45
45
|
@access.set_matrix(%w(read), %w(user group))
|
46
|
-
@access.user_can_read.
|
47
|
-
@access.group_can_read.
|
46
|
+
expect(@access.user_can_read).to eq(true)
|
47
|
+
expect(@access.group_can_read).to eq(true)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "sets four values in the matrix of permissions and roles" do
|
51
51
|
@access.set_matrix(%w(read write), %w(user group))
|
52
|
-
@access.user_can_read.
|
53
|
-
@access.group_can_read.
|
54
|
-
@access.user_can_write.
|
55
|
-
@access.group_can_write.
|
52
|
+
expect(@access.user_can_read).to eq(true)
|
53
|
+
expect(@access.group_can_read).to eq(true)
|
54
|
+
expect(@access.user_can_write).to eq(true)
|
55
|
+
expect(@access.group_can_write).to eq(true)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "parse options hash" do
|
59
59
|
@access.parse(:user_can => :read)
|
60
|
-
@access.user_can_read.
|
60
|
+
expect(@access.user_can_read).to eq(true)
|
61
61
|
end
|
62
62
|
|
63
63
|
it "generates octal permissions from its member vars" do
|
64
64
|
@access.user_can_read = true
|
65
|
-
@access.octal_permissions.
|
65
|
+
expect(@access.octal_permissions).to eq(0400)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "generates octal permissions from its member vars" do
|
@@ -71,7 +71,7 @@ describe Rush::Access do
|
|
71
71
|
@access.user_can_execute = true
|
72
72
|
@access.group_can_read = true
|
73
73
|
@access.group_can_execute = true
|
74
|
-
@access.octal_permissions.
|
74
|
+
expect(@access.octal_permissions).to eq(0750)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "applies its settings to a file" do
|
@@ -80,7 +80,7 @@ describe Rush::Access do
|
|
80
80
|
system "rm -rf #{file}; touch #{file}; chmod 770 #{file}"
|
81
81
|
@access.user_can_read = true
|
82
82
|
@access.apply(file)
|
83
|
-
`ls -l #{file}
|
83
|
+
expect(`ls -l #{file}`).to match(/^-r--------/)
|
84
84
|
ensure
|
85
85
|
system "rm -rf #{file}; touch #{file}"
|
86
86
|
end
|
@@ -88,47 +88,47 @@ describe Rush::Access do
|
|
88
88
|
|
89
89
|
it "serializes itself to a hash" do
|
90
90
|
@access.user_can_read = true
|
91
|
-
@access.to_hash.
|
91
|
+
expect(@access.to_hash).to eq({
|
92
92
|
:user_can_read => 1, :user_can_write => 0, :user_can_execute => 0,
|
93
93
|
:group_can_read => 0, :group_can_write => 0, :group_can_execute => 0,
|
94
94
|
:other_can_read => 0, :other_can_write => 0, :other_can_execute => 0,
|
95
|
-
}
|
95
|
+
})
|
96
96
|
end
|
97
97
|
|
98
98
|
it "unserializes from a hash" do
|
99
99
|
@access.from_hash(:user_can_read => '1')
|
100
|
-
@access.user_can_read.
|
100
|
+
expect(@access.user_can_read).to eq(true)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "initializes from a serialized hash" do
|
104
|
-
@access.class.
|
105
|
-
@access.class.from_hash(:user_can_read => '1').
|
106
|
-
@access.user_can_read.
|
104
|
+
expect(@access.class).to receive(:new).and_return(@access)
|
105
|
+
expect(@access.class.from_hash(:user_can_read => '1')).to eq(@access)
|
106
|
+
expect(@access.user_can_read).to eq(true)
|
107
107
|
end
|
108
108
|
|
109
109
|
it "initializes from a parsed options hash" do
|
110
|
-
@access.class.
|
111
|
-
@access.class.parse(:user_and_group_can => :read).
|
112
|
-
@access.user_can_read.
|
110
|
+
expect(@access.class).to receive(:new).and_return(@access)
|
111
|
+
expect(@access.class.parse(:user_and_group_can => :read)).to eq(@access)
|
112
|
+
expect(@access.user_can_read).to eq(true)
|
113
113
|
end
|
114
114
|
|
115
115
|
it "converts and octal integer into an array of integers" do
|
116
|
-
@access.octal_integer_array(0740).
|
116
|
+
expect(@access.octal_integer_array(0740)).to eq([ 7, 4, 0 ])
|
117
117
|
end
|
118
118
|
|
119
119
|
it "filters out anything above the top three digits (File.stat returns some extra data there)" do
|
120
|
-
@access.octal_integer_array(0100644).
|
120
|
+
expect(@access.octal_integer_array(0100644)).to eq([ 6, 4, 4 ])
|
121
121
|
end
|
122
122
|
|
123
123
|
it "taskes permissions from an octal representation" do
|
124
124
|
@access.from_octal(0644)
|
125
|
-
@access.user_can_read.
|
126
|
-
@access.user_can_write.
|
127
|
-
@access.user_can_execute.
|
125
|
+
expect(@access.user_can_read).to eq(true)
|
126
|
+
expect(@access.user_can_write).to eq(true)
|
127
|
+
expect(@access.user_can_execute).to eq(false)
|
128
128
|
end
|
129
129
|
|
130
130
|
it "computes a display hash by dropping false keys and converting the 1s to trues" do
|
131
|
-
@access.
|
132
|
-
@access.display_hash.
|
131
|
+
expect(@access).to receive(:to_hash).and_return(:red => 1, :green => 0, :blue => 1)
|
132
|
+
expect(@access.display_hash).to eq({ :red => true, :blue => true })
|
133
133
|
end
|
134
134
|
end
|
data/spec/array_ext_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
|
3
3
|
describe Array do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
it 'mixes commands into array' do
|
5
|
+
expect([1, 2, 3].entries).to eq([1, 2, 3])
|
6
|
+
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
it 'can call head' do
|
9
|
+
expect([1, 2, 3].head(1)).to eq([1])
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
it 'can call tail' do
|
13
|
+
expect([1, 2, 3].tail(1)).to eq([3])
|
14
|
+
end
|
15
15
|
end
|
data/spec/box_spec.rb
CHANGED
@@ -1,76 +1,76 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
|
3
3
|
describe Rush::Box do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
4
|
+
before do
|
5
|
+
@sandbox_dir = "/tmp/rush_spec.#{Process.pid}"
|
6
|
+
system "rm -rf #{@sandbox_dir}; mkdir -p #{@sandbox_dir}"
|
7
|
+
|
8
|
+
@box = Rush::Box.new('localhost')
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
system "rm -rf #{@sandbox_dir}"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "looks up entries with [] syntax" do
|
16
|
+
expect(@box['/']).to eq Rush::Dir.new('/', @box)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "looks up processes" do
|
20
|
+
expect(@box.connection).to receive(:processes).and_return([{ :pid => 123 }])
|
21
|
+
expect(@box.processes).to eq [Rush::Process.new({ :pid => 123 }, @box)]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "executes bash commands" do
|
25
|
+
expect(@box.connection).to receive(:bash).with('cmd', nil, false, false).and_return('output')
|
26
|
+
expect(@box.bash('cmd')).to eq 'output'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "executes bash commands with an optional user" do
|
30
|
+
expect(@box.connection).to receive(:bash).with('cmd', 'user', false, false)
|
31
|
+
@box.bash('cmd', :user => 'user')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "executes bash commands in the background, returning a Rush::Process" do
|
35
|
+
expect(@box.connection).to receive(:bash).with('cmd', nil, true, false).and_return(123)
|
36
|
+
allow(@box).to receive(:processes).and_return([double('ps', :pid => 123)])
|
37
|
+
expect(@box.bash('cmd', :background => true).pid).to eq 123
|
38
|
+
end
|
39
|
+
|
40
|
+
it "builds a script of environment variables to prefix the bash command" do
|
41
|
+
expect(@box.command_with_environment('cmd', { :a => 'b' })).to eq "export a=\"b\"\ncmd"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "escapes quotes on environment variables" do
|
45
|
+
expect(@box.command_with_environment('cmd', { :a => 'a"b' })).to eq "export a=\"a\\\"b\"\ncmd"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "escapes backticks on environment variables" do
|
49
|
+
expect(@box.command_with_environment('cmd', { :a => 'a`b' })).to eq "export a=\"a\\\`b\"\ncmd"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "converts environment variables to_s" do
|
53
|
+
expect(@box.command_with_environment('cmd', { :a => nil, :b => 123 })).to eq "export a=\"\"\nexport b=\"123\"\ncmd"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "sets the environment variables from the provided hash" do
|
57
|
+
allow(@box.connection).to receive(:bash)
|
58
|
+
expect(@box).to receive(:command_with_environment).with('cmd', { 1 => 2 })
|
59
|
+
@box.bash('cmd', :env => { 1 => 2 })
|
60
|
+
end
|
61
|
+
|
62
|
+
it "checks the connection to determine if it is alive" do
|
63
|
+
expect(@box.connection).to receive(:alive?).and_return(true)
|
64
|
+
expect(@box).to be_alive
|
65
|
+
end
|
66
|
+
|
67
|
+
it "establish_connection to set up the connection manually" do
|
68
|
+
expect(@box.connection).to receive(:ensure_tunnel)
|
69
|
+
@box.establish_connection
|
70
|
+
end
|
71
|
+
|
72
|
+
it "establish_connection can take a hash of options" do
|
73
|
+
expect(@box.connection).to receive(:ensure_tunnel).with(:timeout => :infinite)
|
74
|
+
@box.establish_connection(:timeout => :infinite)
|
75
|
+
end
|
76
76
|
end
|