soloist 1.0.0.pre → 1.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.
- data/.gitignore +3 -0
- data/.pairs +14 -0
- data/.rvmrc +1 -1
- data/.travis.yml +0 -2
- data/Gemfile.lock +23 -9
- data/Guardfile +6 -1
- data/{MIT-LICENSE → LICENSE} +20 -20
- data/{README.markdown → README.md} +2 -2
- data/Vagrantfile +21 -0
- data/examples/Guardfile +13 -0
- data/examples/soloistrc +2 -0
- data/lib/soloist/cli.rb +39 -44
- data/lib/soloist/config.rb +76 -13
- data/lib/soloist/remote.rb +66 -0
- data/lib/soloist/remote_config.rb +62 -0
- data/lib/soloist/version.rb +1 -1
- data/script/bootstrap.sh +54 -0
- data/soloist.gemspec +3 -0
- data/spec/helpers/net_ssh_test_helper.rb +8 -0
- data/spec/helpers/net_ssh_test_patch.rb +38 -0
- data/spec/lib/soloist/cli_spec.rb +72 -51
- data/spec/lib/soloist/config_spec.rb +147 -58
- data/spec/lib/soloist/remote_config_spec.rb +84 -0
- data/spec/lib/soloist/remote_spec.rb +135 -0
- data/spec/lib/soloist/spotlight_spec.rb +2 -3
- data/spec/spec_helper.rb +9 -0
- metadata +70 -7
@@ -0,0 +1,135 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Soloist::Remote do
|
4
|
+
include Net::SSH::Test
|
5
|
+
|
6
|
+
subject { Soloist::Remote.new("user", "host", "key") }
|
7
|
+
|
8
|
+
before { subject.connection = connection }
|
9
|
+
|
10
|
+
shared_examples "ssh exec" do |command|
|
11
|
+
let(:stdio) { double(:stdio, :<< => nil) }
|
12
|
+
|
13
|
+
before { subject.stub(:stdout => stdio, :stderr => stdio) }
|
14
|
+
|
15
|
+
context "when properly connected" do
|
16
|
+
before do
|
17
|
+
make_story_channel do |channel|
|
18
|
+
channel.sends_exec command
|
19
|
+
channel.gets_data "endless bummer"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns standard output" do
|
24
|
+
stdio.should_receive(:<<).with("endless bummer")
|
25
|
+
described_function
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets the exit status" do
|
29
|
+
expect { described_function }.to change { subject.exitstatus }.to(0)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when execution fails" do
|
34
|
+
before do
|
35
|
+
make_story_channel do |channel|
|
36
|
+
channel.sends_exec command,
|
37
|
+
true, false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises ExecutionFailed" do
|
42
|
+
expect { described_function }.to raise_error(Soloist::RemoteError)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when the command exits" do
|
47
|
+
before do
|
48
|
+
make_story_channel do |channel|
|
49
|
+
channel.sends_exec command
|
50
|
+
channel.gets_extended_data "yodawg i put an error in your error"
|
51
|
+
channel.gets_exit_status(127)
|
52
|
+
end
|
53
|
+
subject.stub(:stderr => stdio)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns the exit status" do
|
57
|
+
expect { described_function }.to change { subject.exitstatus }.to(127)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "sends output to stderr" do
|
61
|
+
subject.stderr.should_receive(:<<).with("yodawg i put an error in your error")
|
62
|
+
described_function
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#backtick" do
|
68
|
+
let(:described_function) { subject.backtick("not-a-japanese-band") }
|
69
|
+
it_behaves_like "ssh exec", "not-a-japanese-band"
|
70
|
+
|
71
|
+
it "returns stdout" do
|
72
|
+
subject.should_receive(:exec) do
|
73
|
+
subject.stdout << "wut"
|
74
|
+
end
|
75
|
+
described_function.should == "wut"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#system" do
|
80
|
+
let(:described_function) { subject.system("i-blame-the-system-man") }
|
81
|
+
it_behaves_like "ssh exec", "i-blame-the-system-man"
|
82
|
+
|
83
|
+
it "returns the exit code" do
|
84
|
+
subject.instance_variable_set(:@exitstatus, 666)
|
85
|
+
subject.should_receive(:exec)
|
86
|
+
described_function.should == 666
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#system!" do
|
91
|
+
it "calls through to system" do
|
92
|
+
subject.should_receive(:system).and_return(0)
|
93
|
+
subject.system!("whatever-dude")
|
94
|
+
end
|
95
|
+
|
96
|
+
it "does not raise an exception if there is no error" do
|
97
|
+
subject.stub(:system => 0)
|
98
|
+
expect { subject.system!("totally-chill-or-whatever") }.not_to raise_error
|
99
|
+
end
|
100
|
+
|
101
|
+
it "raises an exception if there is an error" do
|
102
|
+
subject.stub(:system => 1)
|
103
|
+
expect { subject.system!("omg-wtf") }.to raise_error(Soloist::RemoteError)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#upload" do
|
108
|
+
it "runs rsync with the specified arguments" do
|
109
|
+
Kernel.should_receive(:system).with("rsync -e 'ssh -i key' -avz --delete from user@host:to opts")
|
110
|
+
subject.upload("from", "to", "opts")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe ".from_uri" do
|
115
|
+
context "when a user is provided" do
|
116
|
+
subject { Soloist::Remote.from_uri("destructo@1.2.3.4") }
|
117
|
+
|
118
|
+
its(:user) { should == "destructo" }
|
119
|
+
its(:host) { should == "1.2.3.4" }
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when a user is not provided" do
|
123
|
+
it "sets the correct user" do
|
124
|
+
Etc.should_receive(:getlogin).and_return("jim-bob")
|
125
|
+
Soloist::Remote.from_uri("1.2.3.4").user.should == "jim-bob"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "when a key is provided" do
|
130
|
+
subject { Soloist::Remote.from_uri("dude@whatever", "yo-some-key") }
|
131
|
+
|
132
|
+
its(:key) { should == "yo-some-key" }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Soloist::Spotlight do
|
4
|
-
let(:
|
5
|
-
let(:shallow_path) { File.expand_path("beans/roger", tempdir) }
|
4
|
+
let(:shallow_path) { File.expand_path("beans/roger", RSpec.configuration.tempdir) }
|
6
5
|
let(:spotlight) { Soloist::Spotlight.new(shallow_path) }
|
7
6
|
|
8
7
|
before { FileUtils.mkdir_p(shallow_path) }
|
@@ -49,7 +48,7 @@ describe Soloist::Spotlight do
|
|
49
48
|
before { FileUtils.touch(file_path) }
|
50
49
|
|
51
50
|
it "finds a soloistrc in the current directory" do
|
52
|
-
spotlight.find("soloistrc").to_s.should
|
51
|
+
spotlight.find("soloistrc").to_s.should =~ /\/beans\/roger\/soloistrc$/
|
53
52
|
end
|
54
53
|
|
55
54
|
context "inside a deeper directory" do
|
data/spec/spec_helper.rb
CHANGED
@@ -4,3 +4,12 @@ require "soloist"
|
|
4
4
|
require "tempfile"
|
5
5
|
require "json"
|
6
6
|
require "tmpdir"
|
7
|
+
require "net/ssh/test"
|
8
|
+
|
9
|
+
Dir.glob(File.expand_path("../helpers/**/*.rb", __FILE__)) { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.add_setting :tempdir
|
13
|
+
config.before(:each) { RSpec.configuration.tempdir = Dir.mktmpdir }
|
14
|
+
config.after(:each) { FileUtils.rm_rf(RSpec.configuration.tempdir) }
|
15
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soloist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matthew Kocher
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|
@@ -76,6 +76,38 @@ dependencies:
|
|
76
76
|
- - ! '>='
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: net-ssh
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: awesome_print
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
79
111
|
- !ruby/object:Gem::Dependency
|
80
112
|
name: rspec
|
81
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +156,22 @@ dependencies:
|
|
124
156
|
- - ! '>='
|
125
157
|
- !ruby/object:Gem::Version
|
126
158
|
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: guard-shell
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
type: :development
|
168
|
+
prerelease: false
|
169
|
+
version_requirements: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
127
175
|
- !ruby/object:Gem::Dependency
|
128
176
|
name: rb-fsevent
|
129
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,25 +230,36 @@ extensions: []
|
|
182
230
|
extra_rdoc_files: []
|
183
231
|
files:
|
184
232
|
- .gitignore
|
233
|
+
- .pairs
|
185
234
|
- .rspec
|
186
235
|
- .rvmrc
|
187
236
|
- .travis.yml
|
188
237
|
- Gemfile
|
189
238
|
- Gemfile.lock
|
190
239
|
- Guardfile
|
191
|
-
-
|
192
|
-
- README.
|
240
|
+
- LICENSE
|
241
|
+
- README.md
|
242
|
+
- Vagrantfile
|
193
243
|
- bin/soloist
|
244
|
+
- examples/Guardfile
|
245
|
+
- examples/soloistrc
|
194
246
|
- lib/soloist.rb
|
195
247
|
- lib/soloist/cli.rb
|
196
248
|
- lib/soloist/config.rb
|
249
|
+
- lib/soloist/remote.rb
|
250
|
+
- lib/soloist/remote_config.rb
|
197
251
|
- lib/soloist/royal_crown.rb
|
198
252
|
- lib/soloist/spotlight.rb
|
199
253
|
- lib/soloist/version.rb
|
254
|
+
- script/bootstrap.sh
|
200
255
|
- script/ci.sh
|
201
256
|
- soloist.gemspec
|
257
|
+
- spec/helpers/net_ssh_test_helper.rb
|
258
|
+
- spec/helpers/net_ssh_test_patch.rb
|
202
259
|
- spec/lib/soloist/cli_spec.rb
|
203
260
|
- spec/lib/soloist/config_spec.rb
|
261
|
+
- spec/lib/soloist/remote_config_spec.rb
|
262
|
+
- spec/lib/soloist/remote_spec.rb
|
204
263
|
- spec/lib/soloist/royal_crown_spec.rb
|
205
264
|
- spec/lib/soloist/spotlight_spec.rb
|
206
265
|
- spec/spec_helper.rb
|
@@ -219,9 +278,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
279
|
none: false
|
221
280
|
requirements:
|
222
|
-
- - ! '
|
281
|
+
- - ! '>='
|
223
282
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
283
|
+
version: '0'
|
225
284
|
requirements: []
|
226
285
|
rubyforge_project: soloist
|
227
286
|
rubygems_version: 1.8.24
|
@@ -229,8 +288,12 @@ signing_key:
|
|
229
288
|
specification_version: 3
|
230
289
|
summary: Soloist is a simple way of running chef-solo
|
231
290
|
test_files:
|
291
|
+
- spec/helpers/net_ssh_test_helper.rb
|
292
|
+
- spec/helpers/net_ssh_test_patch.rb
|
232
293
|
- spec/lib/soloist/cli_spec.rb
|
233
294
|
- spec/lib/soloist/config_spec.rb
|
295
|
+
- spec/lib/soloist/remote_config_spec.rb
|
296
|
+
- spec/lib/soloist/remote_spec.rb
|
234
297
|
- spec/lib/soloist/royal_crown_spec.rb
|
235
298
|
- spec/lib/soloist/spotlight_spec.rb
|
236
299
|
- spec/spec_helper.rb
|