shelly 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,6 +27,8 @@ describe Shelly::CLI::User do
27
27
  Dir.chdir("/projects/foo")
28
28
  File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\nfoo-production:\n") }
29
29
  Shelly::App.stub(:inside_git_repository?).and_return(true)
30
+ @cloudfile = Shelly::Cloudfile.new
31
+ Shelly::Cloudfile.stub(:new).and_return(@cloudfile)
30
32
  end
31
33
 
32
34
  it "should exit with message if command run outside git repository" do
@@ -47,33 +49,30 @@ describe Shelly::CLI::User do
47
49
 
48
50
  context "on success" do
49
51
  it "should receive clouds from the Cloudfile" do
50
- @client.should_receive(:apps).and_return([{"code_name" => "foo-production"}, {"code_name" => "foo-staging"}])
51
- @client.should_receive(:apps_users).and_return(response)
52
+ @client.stub(:app_users).and_return(response)
53
+ @cloudfile.should_receive(:clouds).and_return(["foo-staging", "foo-production"])
52
54
  @cli_user.list
53
55
  end
54
56
 
55
57
  it "should display clouds and users" do
56
- @client.should_receive(:apps).and_return([{"code_name" => "foo-production"}, {"code_name" => "foo-staging"}])
57
- @client.stub(:apps_users).and_return(response)
58
+ @client.stub(:app_users).and_return(response)
58
59
  $stdout.should_receive(:puts).with("Cloud foo-production:")
59
60
  $stdout.should_receive(:puts).with(" user@example.com")
60
- $stdout.should_receive(:puts).with("Cloud foo-staging:")
61
- $stdout.should_receive(:puts).with(" user2@example.com")
62
61
  @cli_user.list
63
62
  end
64
63
  end
65
64
 
66
65
  def response
67
- [{'code_name' => 'foo-production', 'users' => [{'email' => 'user@example.com'}]},
68
- {'code_name' => 'foo-staging', 'users' => [{'name' => 'username2','email' => 'user2@example.com'}]}]
66
+ [{'email' => 'user@example.com'}]
69
67
  end
70
68
 
71
69
  context "on failure" do
72
70
  it "should raise an error if user does not have access to cloud" do
73
- @client.should_receive(:apps).and_return([{"code_name" => "foo-production"}])
74
- @client.stub(:apps_users).and_return(response)
75
- $stdout.should_receive(:puts).with("\e[31mYou have no access to 'foo-staging' cloud defined in Cloudfile\e[0m")
76
- lambda { @cli_user.list }.should raise_error(SystemExit)
71
+ response = {"message" => "Cloud foo-staging not found"}
72
+ exception = Shelly::Client::APIError.new(response.to_json)
73
+ @client.stub(:app_users).and_raise(exception)
74
+ $stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
75
+ @cli_user.list
77
76
  end
78
77
  end
79
78
  end
@@ -94,7 +93,7 @@ describe Shelly::CLI::User do
94
93
  File.delete("Cloudfile")
95
94
  $stdout.should_receive(:puts).with("\e[31mNo Cloudfile found\e[0m")
96
95
  lambda {
97
- @cli_user.list
96
+ @cli_user.add
98
97
  }.should raise_error(SystemExit)
99
98
  end
100
99
 
@@ -110,7 +109,6 @@ describe Shelly::CLI::User do
110
109
  before do
111
110
  @client.should_receive(:send_invitation).with("foo-production", "megan@example.com")
112
111
  @client.should_receive(:send_invitation).with("foo-staging", "megan@example.com")
113
- @client.should_receive(:apps).and_return([{"code_name" => "foo-production"}, {"code_name" => "foo-staging"}])
114
112
  end
115
113
 
116
114
  it "should ask about email" do
@@ -131,9 +129,11 @@ describe Shelly::CLI::User do
131
129
 
132
130
  context "on failure" do
133
131
  it "should raise error if user doesnt have access to cloud" do
134
- @client.should_receive(:apps).and_return([{"code_name" => "foo-production"}])
135
- $stdout.should_receive(:puts).with("\e[31mYou have no access to 'foo-staging' cloud defined in Cloudfile\e[0m")
136
- lambda { @cli_user.add("megan@example.com") }.should raise_error(SystemExit)
132
+ response = {"message" => "Cloud foo-staging not found"}
133
+ exception = Shelly::Client::APIError.new(response.to_json)
134
+ @client.stub(:send_invitation).and_raise(exception)
135
+ $stdout.should_receive(:puts).with(red "You have no access to 'foo-staging' cloud defined in Cloudfile")
136
+ @cli_user.add("megan@example.com")
137
137
  end
138
138
  end
139
139
  end
@@ -100,6 +100,17 @@ describe Shelly::Client do
100
100
  end
101
101
  end
102
102
 
103
+ describe "#cloud_logs" do
104
+ it "should send get request" do
105
+ time = Time.now
106
+ FakeWeb.register_uri(:get, @url + "/apps/staging-foo/deploys", :body => [{:failed => false, :created_at => time},
107
+ {:failed => true, :created_at => time+1}].to_json)
108
+ response = @client.cloud_logs("staging-foo")
109
+ response.should == [{"failed"=>false, "created_at"=>time.to_s},
110
+ {"failed"=>true, "created_at"=>(time+1).to_s}]
111
+ end
112
+ end
113
+
103
114
  describe "#create_app" do
104
115
  it "should send post with app's attributes" do
105
116
  @client.should_receive(:post).with("/apps", :app => {:code_name => "foo", :ruby_version => "1.9.2"})
@@ -108,11 +119,19 @@ describe Shelly::Client do
108
119
  end
109
120
 
110
121
  describe "#app_users" do
111
- it "should send post with app code_names" do
112
- FakeWeb.register_uri(:get, @url + "/apps/staging-foo/users", :body => {:code_name => "staging-foo"}.to_json)
113
- FakeWeb.register_uri(:get, @url + "/apps/production-foo/users", :body => {:code_name => "production-foo"}.to_json)
114
- response = @client.apps_users(["staging-foo", "production-foo"])
115
- response.should == [{"code_name" => "staging-foo"}, {"code_name" => "production-foo"}]
122
+ it "should send get request with app code_names" do
123
+ FakeWeb.register_uri(:get, @url + "/apps/staging-foo/users", :body => [{:email => "test@example.com"},
124
+ {:email => "test2@example.com"}].to_json)
125
+ response = @client.app_users("staging-foo")
126
+ response.should == [{"email" => "test@example.com"}, {"email" => "test2@example.com"}]
127
+ end
128
+ end
129
+
130
+ describe "#app_ips" do
131
+ it "should send get request with app code_name" do
132
+ FakeWeb.register_uri(:get, @url + "/apps/staging-foo/ips", :body => {:mail_server_ip => "10.0.1.1", :web_server_ip => "88.198.21.187"}.to_json)
133
+ response = @client.app_ips("staging-foo")
134
+ response.should == {"mail_server_ip" => "10.0.1.1", "web_server_ip" => "88.198.21.187"}
116
135
  end
117
136
  end
118
137
 
@@ -139,6 +158,22 @@ describe Shelly::Client do
139
158
  end
140
159
  end
141
160
 
161
+ describe "#start_cloud" do
162
+ it "should sent post request with cloud's code_name" do
163
+ FakeWeb.register_uri(:put, @url + "/apps/staging-foo/start", :body => {}.to_json)
164
+ response = @client.start_cloud("staging-foo")
165
+ response.should == {}
166
+ end
167
+ end
168
+
169
+ describe "#stop_cloud" do
170
+ it "should sent delete request with cloud's code_name" do
171
+ FakeWeb.register_uri(:put, @url + "/apps/staging-foo/stop", :body => {}.to_json)
172
+ response = @client.stop_cloud("staging-foo")
173
+ response.should == {}
174
+ end
175
+ end
176
+
142
177
  describe "#ssh_key_available?" do
143
178
  it "should send get request with ssh key" do
144
179
  @client.should_receive(:get).with("/users/new", {:ssh_key => "ssh-key Abb"})
@@ -246,5 +281,16 @@ describe Shelly::Client do
246
281
  @client.put("/account", :name => "new-one")
247
282
  end
248
283
  end
249
- end
250
284
 
285
+ describe "#delete" do
286
+ it "should make DELETE request to given path with parameters" do
287
+ @client.should_receive(:request).with("/account", :delete, :name => "new-one")
288
+ @client.delete("/account", :name => "new-one")
289
+ end
290
+
291
+ it "should make DELETE request to apps with parameters" do
292
+ @client.should_receive(:request).with("/apps/new-one", :delete, {})
293
+ @client.delete("/apps/new-one")
294
+ end
295
+ end
296
+ end
@@ -22,17 +22,4 @@ describe Shelly::Cloudfile do
22
22
  end
23
23
  end
24
24
 
25
- describe "#fetch_users" do
26
- it "should return array to display with clouds and users" do
27
- @cloudfile.write(@hash)
28
- @client.should_receive(:apps_users).and_return(response)
29
- response = @cloudfile.fetch_users
30
- response.should == {"foo-staging" => ["user@example.com"]}
31
- end
32
-
33
- def response
34
- [{'code_name' => 'foo-staging','users' => [{'email' => 'user@example.com'}]}]
35
- end
36
- end
37
-
38
25
  end
metadata CHANGED
@@ -1,156 +1,174 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.28
3
+ version: !ruby/object:Gem::Version
4
+ hash: 37
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 29
10
+ version: 0.0.29
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Shelly Cloud team
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-12-05 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2011-12-13 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rspec
16
- requirement: &2153283640 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: *2153283640
25
- - !ruby/object:Gem::Dependency
26
- name: rake
27
- requirement: &2153283180 !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
28
24
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *2153283180
36
- - !ruby/object:Gem::Dependency
37
- name: guard
38
- requirement: &2153282720 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
44
32
  type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
45
36
  prerelease: false
46
- version_requirements: *2153282720
47
- - !ruby/object:Gem::Dependency
48
- name: guard-rspec
49
- requirement: &2153282300 !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
50
38
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
55
46
  type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: guard
56
50
  prerelease: false
57
- version_requirements: *2153282300
58
- - !ruby/object:Gem::Dependency
59
- name: growl_notify
60
- requirement: &2153281780 !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
61
52
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
66
60
  type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-rspec
67
64
  prerelease: false
68
- version_requirements: *2153281780
69
- - !ruby/object:Gem::Dependency
70
- name: rb-fsevent
71
- requirement: &2153281320 !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
72
66
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
77
74
  type: :development
78
- prerelease: false
79
- version_requirements: *2153281320
80
- - !ruby/object:Gem::Dependency
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
81
77
  name: fakefs
82
- requirement: &2153280800 !ruby/object:Gem::Requirement
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
83
80
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
88
  type: :development
89
- prerelease: false
90
- version_requirements: *2153280800
91
- - !ruby/object:Gem::Dependency
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
92
91
  name: fakeweb
93
- requirement: &2153280240 !ruby/object:Gem::Requirement
92
+ prerelease: false
93
+ requirement: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
99
102
  type: :development
100
- prerelease: false
101
- version_requirements: *2153280240
102
- - !ruby/object:Gem::Dependency
103
+ version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
103
105
  name: wijet-thor
104
- requirement: &2153278840 !ruby/object:Gem::Requirement
106
+ prerelease: false
107
+ requirement: &id007 !ruby/object:Gem::Requirement
105
108
  none: false
106
- requirements:
109
+ requirements:
107
110
  - - ~>
108
- - !ruby/object:Gem::Version
111
+ - !ruby/object:Gem::Version
112
+ hash: 41
113
+ segments:
114
+ - 0
115
+ - 14
116
+ - 7
109
117
  version: 0.14.7
110
118
  type: :runtime
111
- prerelease: false
112
- version_requirements: *2153278840
113
- - !ruby/object:Gem::Dependency
119
+ version_requirements: *id007
120
+ - !ruby/object:Gem::Dependency
114
121
  name: rest-client
115
- requirement: &2153278380 !ruby/object:Gem::Requirement
122
+ prerelease: false
123
+ requirement: &id008 !ruby/object:Gem::Requirement
116
124
  none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: '0'
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
121
132
  type: :runtime
122
- prerelease: false
123
- version_requirements: *2153278380
124
- - !ruby/object:Gem::Dependency
133
+ version_requirements: *id008
134
+ - !ruby/object:Gem::Dependency
125
135
  name: json
126
- requirement: &2153277920 !ruby/object:Gem::Requirement
136
+ prerelease: false
137
+ requirement: &id009 !ruby/object:Gem::Requirement
127
138
  none: false
128
- requirements:
129
- - - ! '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
132
146
  type: :runtime
133
- prerelease: false
134
- version_requirements: *2153277920
135
- - !ruby/object:Gem::Dependency
147
+ version_requirements: *id009
148
+ - !ruby/object:Gem::Dependency
136
149
  name: wijet-launchy
137
- requirement: &2153277320 !ruby/object:Gem::Requirement
150
+ prerelease: false
151
+ requirement: &id010 !ruby/object:Gem::Requirement
138
152
  none: false
139
- requirements:
140
- - - ! '>='
141
- - !ruby/object:Gem::Version
142
- version: '0'
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ hash: 3
157
+ segments:
158
+ - 0
159
+ version: "0"
143
160
  type: :runtime
144
- prerelease: false
145
- version_requirements: *2153277320
161
+ version_requirements: *id010
146
162
  description: Tool for managing applications and clouds at shellycloud.com
147
- email:
163
+ email:
148
164
  - support@shellycloud.com
149
- executables:
165
+ executables:
150
166
  - shelly
151
167
  extensions: []
168
+
152
169
  extra_rdoc_files: []
153
- files:
170
+
171
+ files:
154
172
  - .gitignore
155
173
  - .travis.yml
156
174
  - Gemfile
@@ -163,6 +181,7 @@ files:
163
181
  - lib/shelly.rb
164
182
  - lib/shelly/app.rb
165
183
  - lib/shelly/cli/command.rb
184
+ - lib/shelly/cli/deploys.rb
166
185
  - lib/shelly/cli/main.rb
167
186
  - lib/shelly/cli/runner.rb
168
187
  - lib/shelly/cli/user.rb
@@ -174,11 +193,13 @@ files:
174
193
  - lib/shelly/user.rb
175
194
  - lib/shelly/version.rb
176
195
  - lib/thor/arguments.rb
196
+ - lib/thor/basic.rb
177
197
  - lib/thor/options.rb
178
198
  - shelly.gemspec
179
199
  - spec/helpers.rb
180
200
  - spec/input_faker.rb
181
201
  - spec/shelly/app_spec.rb
202
+ - spec/shelly/cli/deploys_spec.rb
182
203
  - spec/shelly/cli/main_spec.rb
183
204
  - spec/shelly/cli/runner_spec.rb
184
205
  - spec/shelly/cli/user_spec.rb
@@ -190,38 +211,36 @@ files:
190
211
  - spec/thor/options_spec.rb
191
212
  homepage: http://shellycloud.com
192
213
  licenses: []
214
+
193
215
  post_install_message:
194
216
  rdoc_options: []
195
- require_paths:
217
+
218
+ require_paths:
196
219
  - lib
197
- required_ruby_version: !ruby/object:Gem::Requirement
220
+ required_ruby_version: !ruby/object:Gem::Requirement
198
221
  none: false
199
- requirements:
200
- - - ! '>='
201
- - !ruby/object:Gem::Version
202
- version: '0'
203
- required_rubygems_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ hash: 3
226
+ segments:
227
+ - 0
228
+ version: "0"
229
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
230
  none: false
205
- requirements:
206
- - - ! '>='
207
- - !ruby/object:Gem::Version
208
- version: '0'
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ hash: 3
235
+ segments:
236
+ - 0
237
+ version: "0"
209
238
  requirements: []
239
+
210
240
  rubyforge_project: shelly
211
241
  rubygems_version: 1.8.10
212
242
  signing_key:
213
243
  specification_version: 3
214
244
  summary: Shelly Cloud command line tool
215
- test_files:
216
- - spec/helpers.rb
217
- - spec/input_faker.rb
218
- - spec/shelly/app_spec.rb
219
- - spec/shelly/cli/main_spec.rb
220
- - spec/shelly/cli/runner_spec.rb
221
- - spec/shelly/cli/user_spec.rb
222
- - spec/shelly/client_spec.rb
223
- - spec/shelly/cloudfile_spec.rb
224
- - spec/shelly/model_spec.rb
225
- - spec/shelly/user_spec.rb
226
- - spec/spec_helper.rb
227
- - spec/thor/options_spec.rb
245
+ test_files: []
246
+