soloist-rvm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,76 @@
1
+ require "spec_helper"
2
+
3
+ describe Soloist::RoyalCrown do
4
+ let(:contents) { { "recipes" => ["broken_vim"] } }
5
+ let(:tempfile) do
6
+ Tempfile.new("soloist-royalcrown").tap do |file|
7
+ file.write(YAML.dump(contents))
8
+ file.close
9
+ end
10
+ end
11
+
12
+ let(:royal_crown) { Soloist::RoyalCrown.from_file(tempfile.path) }
13
+
14
+ describe ".from_file" do
15
+ context "when the rc file is empty" do
16
+ let(:tempfile) do
17
+ Tempfile.new("soloist-royalcrown").tap do |file|
18
+ file.close
19
+ end
20
+ end
21
+
22
+ it "loads an empty file" do
23
+ expect { royal_crown }.not_to raise_error
24
+ end
25
+ end
26
+
27
+ it "loads from a yaml file" do
28
+ royal_crown.recipes.should =~ ["broken_vim"]
29
+ end
30
+
31
+ it "defaults nil fields to an empty primitive" do
32
+ royal_crown.node_attributes.should == {}
33
+ end
34
+
35
+ context "when the rc file has ERB tags" do
36
+ let(:tempfile) do
37
+ Tempfile.new("soloist-royalcrown").tap do |file|
38
+ file.write(<<-YAML
39
+ recipes:
40
+ - broken_vim
41
+ node_attributes:
42
+ evaluated: <%= "From ERB" %>
43
+ YAML
44
+ )
45
+ file.close
46
+ end
47
+ end
48
+
49
+ it "evaluates the ERB and parses the resulting YAML" do
50
+ royal_crown.node_attributes.should == {
51
+ "evaluated" => "From ERB"
52
+ }
53
+ royal_crown.recipes.should =~ ["broken_vim"]
54
+ end
55
+ end
56
+ end
57
+
58
+ describe "#save" do
59
+ it "writes the values to a file" do
60
+ royal_crown.recipes = ["hot_rats", "tissue_paper"]
61
+ royal_crown.save
62
+ royal_crown = Soloist::RoyalCrown.from_file(tempfile.path)
63
+ royal_crown.recipes.should =~ ["hot_rats", "tissue_paper"]
64
+ end
65
+ end
66
+
67
+ describe "#to_yaml" do
68
+ it "skips the path attribute" do
69
+ royal_crown.to_yaml.keys.should_not include "path"
70
+ end
71
+
72
+ it "nils out fields that have not been set" do
73
+ royal_crown.to_yaml["node_attributes"].should be_nil
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+
3
+ describe Soloist::Spotlight do
4
+ let(:shallow_path) { File.expand_path("beans/roger", RSpec.configuration.tempdir) }
5
+ let(:spotlight) { Soloist::Spotlight.new(shallow_path) }
6
+
7
+ before { FileUtils.mkdir_p(shallow_path) }
8
+
9
+ describe "#find" do
10
+ context "with non-existent files" do
11
+ it "raises an error with three files" do
12
+ expect do
13
+ begin
14
+ spotlight.find!("larry", "moe", "curly")
15
+ rescue Soloist::NotFound => e
16
+ e.message.should == "Could not find larry, moe or curly"
17
+ raise
18
+ end
19
+ end.to raise_error(Soloist::NotFound)
20
+ end
21
+
22
+ it "raises an error with two files" do
23
+ expect do
24
+ begin
25
+ spotlight.find!("lulz", "wut")
26
+ rescue Soloist::NotFound => e
27
+ e.message.should == "Could not find lulz or wut"
28
+ raise
29
+ end
30
+ end.to raise_error(Soloist::NotFound)
31
+ end
32
+
33
+ it "raises an error with one file" do
34
+ expect do
35
+ begin
36
+ spotlight.find!("whatever.dude")
37
+ rescue Soloist::NotFound => e
38
+ e.message.should == "Could not find whatever.dude"
39
+ raise
40
+ end
41
+ end.to raise_error(Soloist::NotFound)
42
+ end
43
+ end
44
+
45
+ context "when the file exists" do
46
+ let(:file_path) { File.expand_path("soloistrc", shallow_path) }
47
+
48
+ before { FileUtils.touch(file_path) }
49
+
50
+ it "finds a soloistrc in the current directory" do
51
+ spotlight.find("soloistrc").to_s.should =~ /\/beans\/roger\/soloistrc$/
52
+ end
53
+
54
+ context "inside a deeper directory" do
55
+ let(:deep_path) { File.expand_path("meat/hi", shallow_path) }
56
+ let(:spotlight) { Soloist::Spotlight.new(deep_path) }
57
+
58
+ before { FileUtils.mkdir_p(deep_path) }
59
+
60
+ it "finds a soloistrc upwards" do
61
+ spotlight.find("soloistrc").to_s.should == file_path
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,15 @@
1
+ $: << File.expand_path("../../lib", __FILE__)
2
+
3
+ require "soloist"
4
+ require "tempfile"
5
+ require "json"
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 ADDED
@@ -0,0 +1,297 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soloist-rvm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Austin Putman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: librarian
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: hashie
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.2'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.2'
78
+ - !ruby/object:Gem::Dependency
79
+ name: net-ssh
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: awesome_print
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: guard-bundler
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: guard-shell
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: rb-fsevent
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: terminal-notifier-guard
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: gem-release
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ description: Makes running chef-solo possible.
223
+ email:
224
+ - austin@rawfingertips.com
225
+ executables:
226
+ - soloist
227
+ extensions: []
228
+ extra_rdoc_files: []
229
+ files:
230
+ - .gitignore
231
+ - .pairs
232
+ - .rspec
233
+ - .rvmrc
234
+ - .travis.yml
235
+ - Gemfile
236
+ - Gemfile.lock
237
+ - Guardfile
238
+ - LICENSE
239
+ - README.md
240
+ - Vagrantfile
241
+ - bin/soloist
242
+ - examples/Guardfile
243
+ - examples/soloistrc
244
+ - lib/soloist.rb
245
+ - lib/soloist/cli.rb
246
+ - lib/soloist/config.rb
247
+ - lib/soloist/remote.rb
248
+ - lib/soloist/remote_config.rb
249
+ - lib/soloist/royal_crown.rb
250
+ - lib/soloist/spotlight.rb
251
+ - lib/soloist/version.rb
252
+ - script/bootstrap.sh
253
+ - script/ci.sh
254
+ - soloist-rvm.gemspec
255
+ - spec/helpers/net_ssh_test_helper.rb
256
+ - spec/helpers/net_ssh_test_patch.rb
257
+ - spec/lib/soloist/cli_spec.rb
258
+ - spec/lib/soloist/config_spec.rb
259
+ - spec/lib/soloist/remote_config_spec.rb
260
+ - spec/lib/soloist/remote_spec.rb
261
+ - spec/lib/soloist/royal_crown_spec.rb
262
+ - spec/lib/soloist/spotlight_spec.rb
263
+ - spec/spec_helper.rb
264
+ homepage: http://github.com/austinfromboston/soloist
265
+ licenses: []
266
+ post_install_message:
267
+ rdoc_options: []
268
+ require_paths:
269
+ - lib
270
+ required_ruby_version: !ruby/object:Gem::Requirement
271
+ none: false
272
+ requirements:
273
+ - - ! '>='
274
+ - !ruby/object:Gem::Version
275
+ version: '0'
276
+ required_rubygems_version: !ruby/object:Gem::Requirement
277
+ none: false
278
+ requirements:
279
+ - - ! '>='
280
+ - !ruby/object:Gem::Version
281
+ version: '0'
282
+ requirements: []
283
+ rubyforge_project:
284
+ rubygems_version: 1.8.24
285
+ signing_key:
286
+ specification_version: 3
287
+ summary: Soloist-rvm is a way of running chef-solo under rvm
288
+ test_files:
289
+ - spec/helpers/net_ssh_test_helper.rb
290
+ - spec/helpers/net_ssh_test_patch.rb
291
+ - spec/lib/soloist/cli_spec.rb
292
+ - spec/lib/soloist/config_spec.rb
293
+ - spec/lib/soloist/remote_config_spec.rb
294
+ - spec/lib/soloist/remote_spec.rb
295
+ - spec/lib/soloist/royal_crown_spec.rb
296
+ - spec/lib/soloist/spotlight_spec.rb
297
+ - spec/spec_helper.rb