webbynode 0.2.5.beta2 → 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.
Potentially problematic release.
This version of webbynode might be problematic. Click here for more details.
- data/Manifest +10 -3
- data/Rakefile +7 -5
- data/changelog.rdoc +83 -0
- data/lib/templates/backup +1 -1
- data/lib/webbynode/command.rb +3 -1
- data/lib/webbynode/commands/add_key.rb +2 -2
- data/lib/webbynode/commands/addons.rb +84 -0
- data/lib/webbynode/commands/init.rb +13 -1
- data/lib/webbynode/commands/open.rb +21 -0
- data/lib/webbynode/engines/django.rb +5 -0
- data/lib/webbynode/engines/rails3.rb +1 -0
- data/lib/webbynode/git.rb +29 -5
- data/lib/webbynode/io.rb +10 -2
- data/lib/webbynode/option.rb +19 -4
- data/lib/webbynode/parameter.rb +1 -1
- data/lib/webbynode/properties.rb +22 -3
- data/lib/webbynode/remote_executor.rb +14 -4
- data/lib/webbynode/server.rb +1 -1
- data/lib/webbynode/ssh.rb +6 -3
- data/lib/webbynode.rb +3 -1
- data/spec/fixtures/git/config/new_210.11.13.12 +9 -0
- data/spec/fixtures/git/config/new_67.23.79.31 +9 -0
- data/spec/fixtures/git/config/new_67.23.79.32 +9 -0
- data/spec/fixtures/git/config/new_config +9 -0
- data/spec/webbynode/commands/add_key_spec.rb +3 -3
- data/spec/webbynode/commands/addons_spec.rb +181 -0
- data/spec/webbynode/commands/init_spec.rb +33 -0
- data/spec/webbynode/commands/open_spec.rb +31 -0
- data/spec/webbynode/engines/django_spec.rb +12 -0
- data/spec/webbynode/git_spec.rb +59 -23
- data/spec/webbynode/io_spec.rb +28 -4
- data/spec/webbynode/option_spec.rb +13 -2
- data/spec/webbynode/properties_spec.rb +29 -0
- data/spec/webbynode/remote_executor_spec.rb +34 -10
- data/spec/webbynode/server_spec.rb +1 -1
- data/spec/webbynode/ssh_spec.rb +34 -0
- data/webbynode.gemspec +12 -8
- metadata +41 -16
- data/History.txt +0 -4
- data/Manifest.txt +0 -11
- data/devver.rake +0 -174
data/lib/webbynode.rb
CHANGED
@@ -30,6 +30,7 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'django')
|
|
30
30
|
require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'php')
|
31
31
|
require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'all')
|
32
32
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'apps')
|
33
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'addons')
|
33
34
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'init')
|
34
35
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'push')
|
35
36
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'config')
|
@@ -44,12 +45,13 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'stop')
|
|
44
45
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'restart')
|
45
46
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'alias')
|
46
47
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'help')
|
48
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'open')
|
47
49
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'webbies')
|
48
50
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'version')
|
49
51
|
require File.join(File.dirname(__FILE__), 'webbynode', 'application')
|
50
52
|
|
51
53
|
module Webbynode
|
52
|
-
VERSION = '0.
|
54
|
+
VERSION = '1.0.0'
|
53
55
|
end
|
54
56
|
|
55
57
|
class Array
|
@@ -5,7 +5,7 @@ describe Webbynode::Commands::AddKey do
|
|
5
5
|
let(:server) { double("server") }
|
6
6
|
|
7
7
|
it "should have a constant pointing to the ssh key location" do
|
8
|
-
|
8
|
+
LocalSshKey.should == "#{ENV['HOME']}/.ssh/id_rsa.pub"
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should be aliased to addkey" do
|
@@ -15,7 +15,7 @@ describe Webbynode::Commands::AddKey do
|
|
15
15
|
|
16
16
|
context "when successful" do
|
17
17
|
it "should upload the local ssh key into the server" do
|
18
|
-
server.should_receive(:add_ssh_key).with(
|
18
|
+
server.should_receive(:add_ssh_key).with(LocalSshKey, nil)
|
19
19
|
|
20
20
|
cmd = Webbynode::Commands::AddKey.new
|
21
21
|
cmd.should_receive(:server).any_number_of_times.and_return(server)
|
@@ -23,7 +23,7 @@ describe Webbynode::Commands::AddKey do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should create an ssh key with a provided passphrase" do
|
26
|
-
server.should_receive(:add_ssh_key).with(
|
26
|
+
server.should_receive(:add_ssh_key).with(LocalSshKey, "my_passphrase")
|
27
27
|
|
28
28
|
cmd = Webbynode::Commands::AddKey.new("--passphrase=my_passphrase")
|
29
29
|
cmd.should_receive(:server).any_number_of_times.and_return(server)
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# Load Spec Helper
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')
|
3
|
+
|
4
|
+
describe Webbynode::Commands::Addons do
|
5
|
+
let(:io) { double('Io').as_null_object }
|
6
|
+
context 'with no params' do
|
7
|
+
subject do
|
8
|
+
Webbynode::Commands::Addons.new.tap do |cmd|
|
9
|
+
cmd.stub!(:io).and_return(io)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "shows all available addons" do
|
14
|
+
io.should_receive(:log).with('Available add-ons:')
|
15
|
+
io.should_receive(:log).with(' Key Name Description')
|
16
|
+
io.should_receive(:log).with(' ------------ ----------- ------------------------')
|
17
|
+
io.should_receive(:log).with(' beanstalkd Beanstalk Simple, fast workqueue service')
|
18
|
+
io.should_receive(:log).with(' memcached Memcached Distributed memory object caching system')
|
19
|
+
io.should_receive(:log).with(' mongodb MongoDB Document based database engine')
|
20
|
+
io.should_receive(:log).with(' redis Redis Advanced key-value store')
|
21
|
+
subject.execute
|
22
|
+
end
|
23
|
+
|
24
|
+
it "shows installed addons" do
|
25
|
+
io.should_receive(:load_setting).with('addons').and_return(['a', 'b', 'c'])
|
26
|
+
io.should_receive(:log).with('Currently selected add-ons:')
|
27
|
+
io.should_receive(:log).with(' a, b, c')
|
28
|
+
subject.execute
|
29
|
+
end
|
30
|
+
|
31
|
+
it "handles malformed addons setting" do
|
32
|
+
io.should_receive(:load_setting).with('addons').and_return('somemalformedthing')
|
33
|
+
io.should_receive(:log).with("No add-ons currently selected. Use 'wn addons add <name>' to add.")
|
34
|
+
subject.execute
|
35
|
+
end
|
36
|
+
|
37
|
+
it "doesn't show installed addons if none installed" do
|
38
|
+
io.should_receive(:load_setting).with('addons').and_return(nil)
|
39
|
+
io.should_receive(:log).with('Currently selected add-ons').never
|
40
|
+
io.should_receive(:log).with("No add-ons currently selected. Use 'wn addons add <name>' to add.")
|
41
|
+
subject.execute
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context '#remove' do
|
46
|
+
context "with no addon parameter" do
|
47
|
+
subject do
|
48
|
+
Webbynode::Commands::Addons.new('remove').tap do |cmd|
|
49
|
+
cmd.stub!(:io).and_return(io)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "shows error message" do
|
54
|
+
io.should_receive(:log).with("Missing addon to remove. Type 'wn addons' for a list of available addons.")
|
55
|
+
subject.execute
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "with an invalid addon" do
|
60
|
+
subject do
|
61
|
+
Webbynode::Commands::Addons.new('remove', 'nothing').tap do |cmd|
|
62
|
+
cmd.stub!(:io).and_return(io)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it "shows error message" do
|
67
|
+
io.should_receive(:load_setting).with('addons').never
|
68
|
+
io.should_receive(:log).with("Addon nothing doesn't exist. Type 'wn addons' for a list of available addons.")
|
69
|
+
subject.execute
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with an addon not installed" do
|
74
|
+
subject do
|
75
|
+
Webbynode::Commands::Addons.new('remove', 'redis').tap do |cmd|
|
76
|
+
cmd.stub!(:io).and_return(io)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "shows error message" do
|
81
|
+
io.should_receive(:load_setting).with('addons').and_return(['mongodb'])
|
82
|
+
io.should_receive(:log).with("Add-on 'redis' not installed")
|
83
|
+
subject.execute
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "with a valid addon" do
|
88
|
+
subject do
|
89
|
+
Webbynode::Commands::Addons.new('remove', 'mongodb').tap do |cmd|
|
90
|
+
cmd.stub!(:io).and_return(io)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "when addon added" do
|
95
|
+
it "removes de addon" do
|
96
|
+
io.should_receive(:load_setting).with('addons').and_return(['redis', 'mongodb'])
|
97
|
+
io.should_receive(:add_multi_setting).with('addons', ['redis'])
|
98
|
+
io.should_receive(:log).with("Add-on 'mongodb' removed")
|
99
|
+
subject.execute
|
100
|
+
end
|
101
|
+
|
102
|
+
it "removes de addon, leaving an empty array" do
|
103
|
+
io.should_receive(:load_setting).with('addons').and_return(['mongodb'])
|
104
|
+
io.should_receive(:add_multi_setting).with('addons', [])
|
105
|
+
io.should_receive(:log).with("Add-on 'mongodb' removed")
|
106
|
+
subject.execute
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context '#add' do
|
113
|
+
context "with no addon parameter" do
|
114
|
+
subject do
|
115
|
+
Webbynode::Commands::Addons.new('add').tap do |cmd|
|
116
|
+
cmd.stub!(:io).and_return(io)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it "shows error message" do
|
121
|
+
io.should_receive(:log).with("Missing addon to add. Type 'wn addons' for a list of available addons.")
|
122
|
+
subject.execute
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "with an invalid addon" do
|
127
|
+
subject do
|
128
|
+
Webbynode::Commands::Addons.new('add', 'nothing').tap do |cmd|
|
129
|
+
cmd.stub!(:io).and_return(io)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "shows error message" do
|
134
|
+
io.should_receive(:log).with("Addon nothing doesn't exist. Type 'wn addons' for a list of available addons.")
|
135
|
+
subject.execute
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "with a valid addon" do
|
140
|
+
subject do
|
141
|
+
Webbynode::Commands::Addons.new('add', 'mongodb').tap do |cmd|
|
142
|
+
cmd.stub!(:io).and_return(io)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it "handles malformed addons setting" do
|
147
|
+
io.should_receive(:load_setting).with('addons').and_return('somerandomstuff')
|
148
|
+
io.should_receive(:add_multi_setting).with('addons', ['mongodb'])
|
149
|
+
io.should_receive(:log).with("Add-on 'mongodb' added")
|
150
|
+
subject.execute
|
151
|
+
end
|
152
|
+
|
153
|
+
context "when setting does not exist" do
|
154
|
+
it "create the array" do
|
155
|
+
io.should_receive(:load_setting).with('addons').and_return(nil)
|
156
|
+
io.should_receive(:add_multi_setting).with('addons', ['mongodb'])
|
157
|
+
io.should_receive(:log).with("Add-on 'mongodb' added")
|
158
|
+
subject.execute
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context "when setting exists" do
|
163
|
+
it "add the engine to the array" do
|
164
|
+
io.should_receive(:load_setting).with('addons').and_return(['redis'])
|
165
|
+
io.should_receive(:add_multi_setting).with('addons', ['redis', 'mongodb'])
|
166
|
+
subject.execute
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context "when addon already added" do
|
171
|
+
it "keep the array as is" do
|
172
|
+
io.should_receive(:load_setting).with('addons').and_return(['mongodb'])
|
173
|
+
io.should_receive(:add_multi_setting).never
|
174
|
+
io.should_receive(:log).with("Add-on 'mongodb' added").never
|
175
|
+
io.should_receive(:log).with("Add-on 'mongodb' was already included")
|
176
|
+
subject.execute
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -16,6 +16,8 @@ describe Webbynode::Commands::Init do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
before(:each) do
|
19
|
+
server = stub('Server').as_null_object
|
20
|
+
Webbynode::Server.stub!(:new).and_return(server)
|
19
21
|
FakeWeb.clean_registry
|
20
22
|
create_init
|
21
23
|
git_handler.stub!(:remote_exists?).and_return(false)
|
@@ -41,6 +43,37 @@ describe Webbynode::Commands::Init do
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
46
|
+
describe 'using alternate port' do
|
47
|
+
subject do
|
48
|
+
Webbynode::Commands::Init.new('2.1.2.3', '--port=2020').tap do |cmd|
|
49
|
+
cmd.stub!(:git_present).and_return(:false)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "calls add_remote with the specified port" do
|
54
|
+
git_handler.stub!(:present?).and_return(:false)
|
55
|
+
git_handler.should_receive(:add_remote).with("webbynode", "2.1.2.3", anything(), 2020)
|
56
|
+
|
57
|
+
subject.stub!(:git).and_return(git_handler)
|
58
|
+
subject.stub!(:detect_engine).and_return(Webbynode::Engines::Rails)
|
59
|
+
|
60
|
+
subject.run
|
61
|
+
end
|
62
|
+
|
63
|
+
it "fails when port is not numeric" do
|
64
|
+
git_handler.stub!(:present?).and_return(:false)
|
65
|
+
|
66
|
+
cmd = Webbynode::Commands::Init.new('2.1.2.3', '--port=nonvalid')
|
67
|
+
cmd.stub!(:git).and_return(git_handler)
|
68
|
+
cmd.stub!(:detect_engine).and_return(Webbynode::Engines::Rails)
|
69
|
+
|
70
|
+
cmd.should_receive(:puts).any_number_of_times do |str|
|
71
|
+
str.include?("Invalid value 'nonvalid' for option 'port'. It should be an integer.")
|
72
|
+
end
|
73
|
+
cmd.run
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
44
77
|
describe '#detect_engine' do
|
45
78
|
before(:each) do
|
46
79
|
subject.stub!(:io).and_return(io_handler)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Load Spec Helper
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')
|
3
|
+
|
4
|
+
describe Webbynode::Commands::Open do
|
5
|
+
let(:re) { double("RemoteExecutor").as_null_object }
|
6
|
+
let(:io) { double("Io").as_null_object }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
Webbynode::Commands::Open.new.tap do |cmd|
|
10
|
+
cmd.stub!(:remote_executor).and_return(re)
|
11
|
+
cmd.stub!(:io).and_return(io)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "detects the app URL and opens in browser" do
|
16
|
+
io.should_receive(:app_name).and_return('myapp')
|
17
|
+
re.should_receive(:exec).with("test -f /var/webbynode/mappings/myapp.conf && cat /var/webbynode/mappings/myapp.conf", false).and_return("www.cade.com\n")
|
18
|
+
Launchy.should_receive(:open).with('http://www.cade.com')
|
19
|
+
|
20
|
+
subject.execute
|
21
|
+
end
|
22
|
+
|
23
|
+
it "shows an error message and exit if app not found remotely" do
|
24
|
+
io.should_receive(:app_name).and_return('myapp')
|
25
|
+
re.should_receive(:exec).with("test -f /var/webbynode/mappings/myapp.conf && cat /var/webbynode/mappings/myapp.conf", false).and_return("")
|
26
|
+
Launchy.should_receive(:open).never
|
27
|
+
io.should_receive(:log).with("Application not found or not deployed.")
|
28
|
+
|
29
|
+
subject.execute
|
30
|
+
end
|
31
|
+
end
|
@@ -32,8 +32,19 @@ describe Webbynode::Engines::Django do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#prepare' do
|
35
|
+
context 'when settings.py is missing' do
|
36
|
+
it "raises an error" do
|
37
|
+
io.should_receive(:file_exists?).with('settings.py').and_return(false)
|
38
|
+
io.should_receive(:file_exists?).with('settings.template.py').never
|
39
|
+
io.should_receive(:copy_file).never
|
40
|
+
|
41
|
+
lambda { subject.prepare }.should raise_error(Webbynode::Command::CommandError, "Couldn't create the settings template because settings.py was not found. Please check and try again.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
35
45
|
context "when settings.template.py doesn't exist" do
|
36
46
|
it "creates settings.template.py based on settings.py" do
|
47
|
+
io.should_receive(:file_exists?).with('settings.py').and_return(true)
|
37
48
|
io.should_receive(:file_exists?).with('settings.template.py').and_return(false)
|
38
49
|
io.should_receive(:copy_file).with('settings.py', 'settings.template.py')
|
39
50
|
io.should_receive(:log).with('Creating settings.template.py from your settings.py...')
|
@@ -54,6 +65,7 @@ describe Webbynode::Engines::Django do
|
|
54
65
|
context "when settings.template.py exists" do
|
55
66
|
it "doesn't do anything" do
|
56
67
|
io.should_receive(:log).never
|
68
|
+
io.should_receive(:file_exists?).with('settings.py').and_return(true)
|
57
69
|
io.should_receive(:file_exists?).with('settings.template.py').and_return(true)
|
58
70
|
io.should_receive(:copy_file).never
|
59
71
|
subject.should_receive(:change_settings).never
|
data/spec/webbynode/git_spec.rb
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
|
3
3
|
|
4
4
|
describe Webbynode::Git do
|
5
|
+
let(:re) { double('RemoteExecutor') }
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
Webbynode::RemoteExecutor.stub!(:new).and_return(re)
|
9
|
+
end
|
10
|
+
|
5
11
|
def should_raise_when_response(exception, command, response, &blk)
|
6
12
|
io_handler = mock("io")
|
7
13
|
io_handler.should_receive(:exec).with(command).and_return(response)
|
@@ -27,6 +33,7 @@ describe Webbynode::Git do
|
|
27
33
|
end
|
28
34
|
|
29
35
|
it "should have an io instance" do
|
36
|
+
pending "Check out why this is being mocked"
|
30
37
|
Webbynode::Git.new.io.class.should == Webbynode::Io
|
31
38
|
end
|
32
39
|
|
@@ -192,30 +199,40 @@ describe Webbynode::Git do
|
|
192
199
|
end
|
193
200
|
|
194
201
|
describe "#add_remote" do
|
202
|
+
before(:each) do
|
203
|
+
re.should_receive(:remote_home).and_return('/var/rapp')
|
204
|
+
end
|
205
|
+
|
206
|
+
it "connects to the remote IP to get home folder" do
|
207
|
+
Webbynode::RemoteExecutor.should_receive(:new).with("1.2.3.4", 389).and_return(re)
|
208
|
+
|
209
|
+
subject.should_receive(:exec).with("git remote add webbynode ssh://git@1.2.3.4:389/var/rapp/the_repo")
|
210
|
+
subject.add_remote("webbynode", "1.2.3.4", "the_repo", 389)
|
211
|
+
end
|
212
|
+
|
195
213
|
context "when successfull" do
|
196
214
|
it "should create a new remote" do
|
197
215
|
io_handler = mock("io")
|
198
|
-
io_handler.should_receive(:exec).with("git remote add webbynode git@1.2.3.4:the_repo").and_return("")
|
216
|
+
io_handler.should_receive(:exec).with("git remote add webbynode ssh://git@1.2.3.4:22/var/rapp/the_repo").and_return("")
|
199
217
|
|
200
|
-
|
201
|
-
|
202
|
-
git.add_remote("webbynode", "1.2.3.4", "the_repo").should be_true
|
218
|
+
subject.should_receive(:io).and_return(io_handler)
|
219
|
+
subject.add_remote("webbynode", "1.2.3.4", "the_repo").should be_true
|
203
220
|
end
|
204
221
|
end
|
205
222
|
|
206
223
|
context "when unsuccessfull" do
|
207
224
|
it "should raise exception if not a git repo" do
|
208
|
-
should_raise_notgitrepo("git remote add other git@5.6.7.8:a_repo") { |git| git.add_remote("other", "5.6.7.8", "a_repo") }
|
225
|
+
should_raise_notgitrepo("git remote add other ssh://git@5.6.7.8:22/var/rapp/a_repo") { |git| git.add_remote("other", "5.6.7.8", "a_repo") }
|
209
226
|
end
|
210
227
|
|
211
228
|
it "should return raise exception if the remote already exists" do
|
212
|
-
should_raise(Webbynode::GitRemoteAlreadyExistsError, "git remote add other git@5.6.7.8:a_repo") { |git|
|
229
|
+
should_raise(Webbynode::GitRemoteAlreadyExistsError, "git remote add other ssh://git@5.6.7.8:22/var/rapp/a_repo") { |git|
|
213
230
|
git.add_remote("other", "5.6.7.8", "a_repo")
|
214
231
|
}
|
215
232
|
end
|
216
233
|
|
217
234
|
it "should raise a generic Git error when another error occurs" do
|
218
|
-
should_raise_giterror("git remote add other git@5.6.7.8:a_repo") { |git| git.add_remote("other", "5.6.7.8", "a_repo") }
|
235
|
+
should_raise_giterror("git remote add other ssh://git@5.6.7.8:22/var/rapp/a_repo") { |git| git.add_remote("other", "5.6.7.8", "a_repo") }
|
219
236
|
end
|
220
237
|
end
|
221
238
|
end
|
@@ -375,26 +392,45 @@ describe Webbynode::Git do
|
|
375
392
|
end
|
376
393
|
end
|
377
394
|
|
395
|
+
describe "parsing the remote url" do
|
396
|
+
let(:io_handler) { mock("io").as_null_object }
|
378
397
|
|
379
|
-
|
380
|
-
|
381
|
-
it "should parse the configuration file" do
|
382
|
-
git = Webbynode::Git.new
|
383
|
-
git.should_receive(:parse_config)
|
384
|
-
git.parse_remote_ip
|
385
|
-
end
|
386
|
-
|
387
|
-
it "should extract the remote ip from the parsed configuration file" do
|
388
|
-
io_handler = mock("io")
|
389
|
-
io_handler.as_null_object
|
390
|
-
|
398
|
+
describe '#parse_remote_url' do
|
399
|
+
it "returns the URL for the new config model" do
|
391
400
|
git = Webbynode::Git.new
|
392
401
|
git.stub!(:remote_webbynode?).and_return(true)
|
393
402
|
git.should_receive(:io).and_return(io_handler)
|
394
|
-
File.should_receive(:open).exactly(:once).with(".git/config").and_return(read_fixture('git/config/
|
395
|
-
|
396
|
-
git.
|
397
|
-
|
403
|
+
File.should_receive(:open).exactly(:once).with(".git/config").and_return(read_fixture('git/config/new_config'))
|
404
|
+
|
405
|
+
git.parse_remote_url.should == 'ssh://git@1.2.3.4:122/var/rapp/webbynode'
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
describe '#parse_remote_ip' do
|
410
|
+
context "old format" do
|
411
|
+
it "should extract the remote ip and port from the parsed configuration file" do
|
412
|
+
git = Webbynode::Git.new
|
413
|
+
git.stub!(:remote_webbynode?).and_return(true)
|
414
|
+
git.should_receive(:io).and_return(io_handler)
|
415
|
+
File.should_receive(:open).exactly(:once).with(".git/config").and_return(read_fixture('git/config/config'))
|
416
|
+
git.parse_remote_ip
|
417
|
+
git.config.should_not be_empty
|
418
|
+
git.remote_ip.should eql('1.2.3.4')
|
419
|
+
git.remote_port.should eql(22)
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
context "new format" do
|
424
|
+
it "should extract the remote ip and port from the parsed configuration file" do
|
425
|
+
git = Webbynode::Git.new
|
426
|
+
git.stub!(:remote_webbynode?).and_return(true)
|
427
|
+
git.should_receive(:io).and_return(io_handler)
|
428
|
+
File.should_receive(:open).exactly(:once).with(".git/config").and_return(read_fixture('git/config/new_config'))
|
429
|
+
git.parse_remote_ip
|
430
|
+
git.config.should_not be_empty
|
431
|
+
git.remote_ip.should eql('1.2.3.4')
|
432
|
+
git.remote_port.should eql(122)
|
433
|
+
end
|
398
434
|
end
|
399
435
|
end
|
400
436
|
end
|
data/spec/webbynode/io_spec.rb
CHANGED
@@ -57,6 +57,30 @@ describe Webbynode::Io do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe '#add_multi_setting' do
|
61
|
+
let(:io) { Webbynode::Io.new }
|
62
|
+
it "creates an entry with the elements" do
|
63
|
+
props = mock("Hash")
|
64
|
+
props.should_receive(:[]=).with('addons', '(a b c)')
|
65
|
+
props.should_receive(:save)
|
66
|
+
|
67
|
+
io.should_receive(:properties).with(".webbynode/settings").and_return(props)
|
68
|
+
io.add_multi_setting("addons", ['a', 'b', 'c'])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#load_setting' do
|
73
|
+
let(:io) { Webbynode::Io.new }
|
74
|
+
it "loads the properties file" do
|
75
|
+
props = stub("Properties")
|
76
|
+
props.should_receive(:[]).with('addons').and_return(['a', 'b', 'c'])
|
77
|
+
|
78
|
+
# Properties.should_receive(:initialize).with(".webbynode/settings", true).and_return(props)
|
79
|
+
io.should_receive(:properties).with(".webbynode/settings").and_return(props)
|
80
|
+
io.load_setting("addons").should == ['a', 'b', 'c']
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
60
84
|
describe '#remove_setting' do
|
61
85
|
let(:io) { Webbynode::Io.new }
|
62
86
|
|
@@ -73,20 +97,20 @@ describe Webbynode::Io do
|
|
73
97
|
describe '#create_local_key' do
|
74
98
|
describe "when key file missing" do
|
75
99
|
before(:each) do
|
76
|
-
File.should_receive(:exists?).with(
|
100
|
+
File.should_receive(:exists?).with(LocalSshKey).and_return(false)
|
77
101
|
@io = Webbynode::Io.new
|
78
102
|
end
|
79
103
|
|
80
104
|
context "with no passphrase" do
|
81
105
|
it "should create the key with an empty passphrase" do
|
82
|
-
@io.should_receive(:exec).with("ssh-keygen -t rsa -N \"\" -f #{
|
106
|
+
@io.should_receive(:exec).with("ssh-keygen -t rsa -N \"\" -f #{LocalSshKey}").and_return("")
|
83
107
|
@io.create_local_key
|
84
108
|
end
|
85
109
|
end
|
86
110
|
|
87
111
|
context "with a passphrase" do
|
88
112
|
it "should create the key with the provided passphrase" do
|
89
|
-
@io.should_receive(:exec).with("ssh-keygen -t rsa -N \"passphrase\" -f #{
|
113
|
+
@io.should_receive(:exec).with("ssh-keygen -t rsa -N \"passphrase\" -f #{LocalSshKey}").and_return("")
|
90
114
|
@io.create_local_key("passphrase")
|
91
115
|
end
|
92
116
|
end
|
@@ -94,7 +118,7 @@ describe Webbynode::Io do
|
|
94
118
|
|
95
119
|
describe "when key already exists" do
|
96
120
|
before(:each) do
|
97
|
-
File.should_receive(:exists?).with(
|
121
|
+
File.should_receive(:exists?).with(LocalSshKey).and_return(true)
|
98
122
|
@io = Webbynode::Io.new
|
99
123
|
end
|
100
124
|
|
@@ -36,8 +36,19 @@ describe Webbynode::Option do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe "
|
40
|
-
it "
|
39
|
+
describe "validations" do
|
40
|
+
it "assures value is numerif if :numeric passed" do
|
41
|
+
opt = Webbynode::Option.new(:option1, "My option", :validate => :integer )
|
42
|
+
opt.value = 'c'
|
43
|
+
|
44
|
+
error = "Invalid value 'c' for option 'option1'. It should be an integer."
|
45
|
+
|
46
|
+
opt.should_not be_valid
|
47
|
+
opt.errors.should be_include(error)
|
48
|
+
lambda { opt.validate! }.should raise_error(Webbynode::Command::InvalidCommand, error)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "assures values match if :in passed" do
|
41
52
|
opt = Webbynode::Option.new(:option1, "My option", :validate => { :in => ['a', 'b'] })
|
42
53
|
opt.value = 'c'
|
43
54
|
opt.should_not be_valid
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Load Spec Helper
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
|
3
|
+
|
4
|
+
describe Webbynode::Properties do
|
5
|
+
describe '#initialize' do
|
6
|
+
it "loads multi params" do
|
7
|
+
IO.should_receive(:foreach).with('file').and_yield("a=b").and_yield("c=d").and_yield("e=(f g htg1)")
|
8
|
+
$testing = false
|
9
|
+
p = Webbynode::Properties.new('file')
|
10
|
+
$testing = true
|
11
|
+
p['a'].should == 'b'
|
12
|
+
p['c'].should == 'd'
|
13
|
+
p['e'].should == ['f', 'g', 'htg1']
|
14
|
+
end
|
15
|
+
|
16
|
+
it "saves multi params" do
|
17
|
+
file = double('File').as_null_object
|
18
|
+
File.should_receive(:new).with('file', 'w+').and_return(file)
|
19
|
+
file.should_receive(:puts).with("a=(one two three)\n")
|
20
|
+
|
21
|
+
$testing = false
|
22
|
+
properties = Webbynode::Properties.new('file')
|
23
|
+
$testing = true
|
24
|
+
|
25
|
+
properties['a'] = ['one', 'two', 'three']
|
26
|
+
properties.save
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|