dpl-connect 1.8.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +8 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +36 -0
  6. data/Gemfile +100 -0
  7. data/LICENSE +22 -0
  8. data/README.md +934 -0
  9. data/Rakefile +1 -0
  10. data/TESTING.md +29 -0
  11. data/bin/dpl +5 -0
  12. data/dpl.gemspec +32 -0
  13. data/lib/dpl/cli.rb +66 -0
  14. data/lib/dpl/error.rb +3 -0
  15. data/lib/dpl/provider.rb +264 -0
  16. data/lib/dpl/provider/anynines.rb +13 -0
  17. data/lib/dpl/provider/appfog.rb +21 -0
  18. data/lib/dpl/provider/atlas.rb +108 -0
  19. data/lib/dpl/provider/azure_webapps.rb +48 -0
  20. data/lib/dpl/provider/bintray.rb +509 -0
  21. data/lib/dpl/provider/bitballoon.rb +22 -0
  22. data/lib/dpl/provider/bluemix_cloud_foundry.rb +23 -0
  23. data/lib/dpl/provider/boxfuse.rb +57 -0
  24. data/lib/dpl/provider/catalyze.rb +49 -0
  25. data/lib/dpl/provider/chef_supermarket.rb +85 -0
  26. data/lib/dpl/provider/cloud66.rb +38 -0
  27. data/lib/dpl/provider/cloud_files.rb +38 -0
  28. data/lib/dpl/provider/cloud_foundry.rb +43 -0
  29. data/lib/dpl/provider/code_deploy.rb +123 -0
  30. data/lib/dpl/provider/deis.rb +119 -0
  31. data/lib/dpl/provider/divshot.rb +23 -0
  32. data/lib/dpl/provider/elastic_beanstalk.rb +195 -0
  33. data/lib/dpl/provider/engine_yard.rb +90 -0
  34. data/lib/dpl/provider/firebase.rb +27 -0
  35. data/lib/dpl/provider/gae.rb +97 -0
  36. data/lib/dpl/provider/gcs.rb +59 -0
  37. data/lib/dpl/provider/hackage.rb +29 -0
  38. data/lib/dpl/provider/heroku.rb +18 -0
  39. data/lib/dpl/provider/heroku/api.rb +98 -0
  40. data/lib/dpl/provider/heroku/generic.rb +94 -0
  41. data/lib/dpl/provider/heroku/git.rb +28 -0
  42. data/lib/dpl/provider/lambda.rb +236 -0
  43. data/lib/dpl/provider/launchpad.rb +48 -0
  44. data/lib/dpl/provider/modulus.rb +23 -0
  45. data/lib/dpl/provider/npm.rb +64 -0
  46. data/lib/dpl/provider/openshift.rb +59 -0
  47. data/lib/dpl/provider/ops_works.rb +132 -0
  48. data/lib/dpl/provider/packagecloud.rb +144 -0
  49. data/lib/dpl/provider/pages.rb +79 -0
  50. data/lib/dpl/provider/puppet_forge.rb +43 -0
  51. data/lib/dpl/provider/pypi.rb +111 -0
  52. data/lib/dpl/provider/releases.rb +139 -0
  53. data/lib/dpl/provider/rubygems.rb +51 -0
  54. data/lib/dpl/provider/s3.rb +123 -0
  55. data/lib/dpl/provider/scalingo.rb +97 -0
  56. data/lib/dpl/provider/script.rb +29 -0
  57. data/lib/dpl/provider/surge.rb +33 -0
  58. data/lib/dpl/provider/testfairy.rb +190 -0
  59. data/lib/dpl/provider/transifex.rb +45 -0
  60. data/lib/dpl/version.rb +3 -0
  61. data/notes/engine_yard.md +1 -0
  62. data/notes/heroku.md +3 -0
  63. data/spec/cli_spec.rb +36 -0
  64. data/spec/provider/anynines_spec.rb +20 -0
  65. data/spec/provider/appfog_spec.rb +35 -0
  66. data/spec/provider/atlas_spec.rb +99 -0
  67. data/spec/provider/azure_webapps_spec.rb +95 -0
  68. data/spec/provider/bintray_spec.rb +259 -0
  69. data/spec/provider/bitballoon_spec.rb +32 -0
  70. data/spec/provider/bluemixcloudfoundry_spec.rb +23 -0
  71. data/spec/provider/boxfuse_spec.rb +16 -0
  72. data/spec/provider/catalyze_spec.rb +39 -0
  73. data/spec/provider/chef_supermarket_spec.rb +51 -0
  74. data/spec/provider/cloud66_spec.rb +44 -0
  75. data/spec/provider/cloud_files_spec.rb +88 -0
  76. data/spec/provider/cloudfoundry_spec.rb +71 -0
  77. data/spec/provider/code_deploy_spec.rb +360 -0
  78. data/spec/provider/deis_spec.rb +116 -0
  79. data/spec/provider/divshot_spec.rb +28 -0
  80. data/spec/provider/elastic_beanstalk_spec.rb +209 -0
  81. data/spec/provider/firebase_spec.rb +40 -0
  82. data/spec/provider/gae_spec.rb +26 -0
  83. data/spec/provider/gcs_spec.rb +115 -0
  84. data/spec/provider/hackage_spec.rb +47 -0
  85. data/spec/provider/heroku_spec.rb +357 -0
  86. data/spec/provider/lambda_spec.rb +432 -0
  87. data/spec/provider/launchpad_spec.rb +33 -0
  88. data/spec/provider/modulus_spec.rb +29 -0
  89. data/spec/provider/npm_spec.rb +95 -0
  90. data/spec/provider/openshift_spec.rb +91 -0
  91. data/spec/provider/ops_works_spec.rb +127 -0
  92. data/spec/provider/packagecloud_spec.rb +56 -0
  93. data/spec/provider/puppet_forge_spec.rb +60 -0
  94. data/spec/provider/pypi_spec.rb +103 -0
  95. data/spec/provider/releases_spec.rb +303 -0
  96. data/spec/provider/rubygems_spec.rb +106 -0
  97. data/spec/provider/s3_spec.rb +174 -0
  98. data/spec/provider/scalingo_spec.rb +64 -0
  99. data/spec/provider/script_spec.rb +26 -0
  100. data/spec/provider/surge_spec.rb +15 -0
  101. data/spec/provider/testfairy_spec.rb +86 -0
  102. data/spec/provider/transifex_spec.rb +110 -0
  103. data/spec/provider_spec.rb +210 -0
  104. data/spec/spec_helper.rb +20 -0
  105. metadata +279 -0
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/pypi'
3
+
4
+ describe DPL::Provider::PyPI do
5
+ subject :provider do
6
+ described_class.new(DummyContext.new, :user => 'foo', :password => 'bar')
7
+ end
8
+
9
+ describe "#config" do
10
+ it 'accepts a user and a password' do
11
+ expect(provider.config[:servers]['pypi']).to include 'username: foo'
12
+ expect(provider.config[:servers]['pypi']).to include 'password: bar'
13
+ end
14
+ end
15
+
16
+ describe "#initialize" do
17
+ example "with :distributions option containing 'bdist_wheel'" do
18
+ expect(described_class).to receive(:pip).with("wheel")
19
+ described_class.new(DummyContext.new, :user => 'foo', :password => 'bar', :distributions => 'bdist_wheel sdist')
20
+ end
21
+ end
22
+
23
+ describe "#check_auth" do
24
+ example do
25
+ expect(provider).to receive(:log).with("Authenticated as foo")
26
+ provider.check_auth
27
+ end
28
+ end
29
+
30
+ describe "#push_app" do
31
+ example do
32
+ expect(provider.context).to receive(:shell).with("python setup.py sdist")
33
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*")
34
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*")
35
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
36
+ provider.push_app
37
+ end
38
+
39
+ example "with :distributions option" do
40
+ provider.options.update(:distributions => 'sdist bdist')
41
+ expect(provider.context).to receive(:shell).with("python setup.py sdist bdist")
42
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*")
43
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*")
44
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
45
+ provider.push_app
46
+ end
47
+
48
+ example "with :server option" do
49
+ provider.options.update(:server => 'http://blah.com')
50
+ expect(provider.context).to receive(:shell).with("python setup.py sdist")
51
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*")
52
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*")
53
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r http://blah.com")
54
+ provider.push_app
55
+ end
56
+
57
+ example "with :skip_upload_docs option" do
58
+ provider.options.update(:skip_upload_docs => true)
59
+ expect(provider.context).to receive(:shell).with("python setup.py sdist")
60
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*")
61
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*")
62
+ expect(provider.context).not_to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
63
+ provider.push_app
64
+ end
65
+
66
+ context "with :skip_upload_docs option being false" do
67
+ before :each do
68
+ provider.options.update(:skip_upload_docs => false)
69
+ end
70
+
71
+ it "runs upload_docs" do
72
+ expect(provider.context).to receive(:shell).with("python setup.py sdist")
73
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*")
74
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*")
75
+ expect(provider.context).to receive(:shell).with("python setup.py upload_docs -r https://upload.pypi.org/legacy/")
76
+ provider.push_app
77
+ end
78
+
79
+ example "with :docs_dir option" do
80
+ provider.options.update(:docs_dir => 'some/dir')
81
+ expect(provider.context).to receive(:shell).with("python setup.py sdist")
82
+ expect(provider.context).to receive(:shell).with("twine upload -r pypi dist/*")
83
+ expect(provider.context).to receive(:shell).with("rm -rf dist/*")
84
+ expect(provider.context).to receive(:shell).with("python setup.py upload_docs --upload-dir some/dir -r https://upload.pypi.org/legacy/")
85
+ provider.push_app
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ describe "#write_servers" do
92
+ example do
93
+ f = double(:f)
94
+ expect(f).to receive(:puts).with(" pypi")
95
+ expect(f).to receive(:puts).with("[pypi]")
96
+ expect(f).to receive(:puts).with(["repository: https://upload.pypi.org/legacy/",
97
+ "username: foo",
98
+ "password: bar"
99
+ ])
100
+ provider.write_servers(f)
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,303 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/releases'
3
+ require 'octokit'
4
+
5
+ describe DPL::Provider::Releases do
6
+ subject :provider do
7
+ described_class.new(DummyContext.new, :api_key => '0123445789qwertyuiop0123445789qwertyuiop', :file => 'blah.txt')
8
+ end
9
+
10
+ describe "#travis_tag" do
11
+ example "When $TRAVIS_TAG is nil" do
12
+ provider.context.env['TRAVIS_TAG'] = nil
13
+
14
+ expect(provider.travis_tag).to eq(nil)
15
+ end
16
+
17
+ example "When $TRAVIS_TAG if set but empty" do
18
+ provider.context.env['TRAVIS_TAG'] = nil
19
+
20
+ expect(provider.travis_tag).to eq(nil)
21
+ end
22
+
23
+ example "When $TRAVIS_TAG if set" do
24
+ provider.context.env['TRAVIS_TAG'] = "foo"
25
+
26
+ expect(provider.travis_tag).to eq("foo")
27
+ end
28
+ end
29
+
30
+ describe "#api" do
31
+ example "With API key" do
32
+ api = double(:api)
33
+ expect(::Octokit::Client).to receive(:new).with(:access_token => '0123445789qwertyuiop0123445789qwertyuiop').and_return(api)
34
+ expect(provider.api).to eq(api)
35
+ end
36
+
37
+ example "With username and password" do
38
+ api = double(:api)
39
+ provider.options.update(:user => 'foo')
40
+ provider.options.update(:password => 'bar')
41
+
42
+ expect(::Octokit::Client).to receive(:new).with(:login => 'foo', :password => 'bar').and_return(api)
43
+ expect(provider.api).to eq(api)
44
+ end
45
+ end
46
+
47
+ describe "#releases" do
48
+ example "With ENV Slug" do
49
+ allow(provider).to receive(:slug).and_return("foo/bar")
50
+
51
+ expect(provider.api).to receive(:releases).with("foo/bar")
52
+ provider.releases
53
+ end
54
+
55
+ example "With repo option" do
56
+ provider.options.update(:repo => 'bar/foo')
57
+
58
+ expect(provider.api).to receive(:releases).with('bar/foo')
59
+ provider.releases
60
+ end
61
+ end
62
+
63
+ describe "#files" do
64
+ example "without file globbing and a single file" do
65
+ expect(provider.files).to eq(['blah.txt'])
66
+ end
67
+
68
+ example "without file globbing and multiple files" do
69
+ provider.options.update(:file => ['foo.txt', 'bar.txt'])
70
+ expect(provider.files).to eq(['foo.txt', 'bar.txt'])
71
+ end
72
+
73
+ example "with file globbing and a single glob" do
74
+ provider.options.update(:file_glob => true)
75
+ provider.options.update(:file => 'bl*.txt')
76
+ expect(::Dir).to receive(:glob).with('bl*.txt').and_return(['blah.txt'])
77
+ expect(provider.files).to eq(['blah.txt'])
78
+ end
79
+
80
+ example "with file globbing and multiple globs" do
81
+ provider.options.update(:file_glob => true)
82
+ provider.options.update(:file => ['f*.txt', 'b*.txt'])
83
+ expect(::Dir).to receive(:glob).with('f*.txt').and_return(['foo.txt'])
84
+ expect(::Dir).to receive(:glob).with('b*.txt').and_return(['bar.txt'])
85
+ expect(provider.files).to eq(['foo.txt', 'bar.txt'])
86
+ end
87
+ end
88
+
89
+ describe "#needs_key?" do
90
+ example do
91
+ expect(provider.needs_key?).to eq(false)
92
+ end
93
+ end
94
+
95
+ describe "#check_app" do
96
+ example "Without $TRAVIS_TAG" do
97
+ allow(provider).to receive(:travis_tag).and_return(nil)
98
+ allow(provider).to receive(:slug).and_return("foo/bar")
99
+ allow(provider).to receive(:get_tag).and_return("foo")
100
+
101
+ expect(provider.context).to receive(:shell).with("git fetch --tags")
102
+ expect(provider).to receive(:log).with("Deploying to repo: foo/bar")
103
+ expect(provider).to receive(:log).with("Current tag is: foo")
104
+
105
+ provider.check_app
106
+ end
107
+
108
+ example "With $TRAVIS_TAG" do
109
+ allow(provider).to receive(:travis_tag).and_return("bar")
110
+ allow(provider).to receive(:slug).and_return("foo/bar")
111
+
112
+ expect(provider.context).not_to receive(:shell).with("git fetch --tags")
113
+ expect(provider).to receive(:log).with("Deploying to repo: foo/bar")
114
+ expect(provider).to receive(:log).with("Current tag is: bar")
115
+
116
+ provider.check_app
117
+ end
118
+ end
119
+
120
+ describe "#get_tag" do
121
+ example "Without $TRAVIS_TAG" do
122
+ allow(provider).to receive(:travis_tag).and_return(nil)
123
+ allow(provider).to receive(:`).and_return("bar")
124
+
125
+ expect(provider.get_tag).to eq("bar")
126
+ end
127
+
128
+ example "With $TRAVIS_TAG" do
129
+ allow(provider).to receive(:travis_tag).and_return("foo")
130
+
131
+ expect(provider.get_tag).to eq("foo")
132
+ end
133
+ end
134
+
135
+ describe "#check_auth" do
136
+ example "With proper permissions" do
137
+ allow_message_expectations_on_nil
138
+ allow(provider).to receive(:user)
139
+ allow(provider).to receive(:setup_auth)
140
+ expect(provider.api).to receive(:scopes).and_return(["public_repo"])
141
+ expect(provider.user).to receive(:name).and_return("foo")
142
+ expect(provider).to receive(:log).with("Logged in as foo")
143
+ provider.check_auth
144
+ end
145
+
146
+ example "With improper permissions" do
147
+ allow_message_expectations_on_nil
148
+ allow(provider).to receive(:user)
149
+ allow(provider).to receive(:setup_auth)
150
+ expect(provider.api).to receive(:scopes).exactly(2).times.and_return([])
151
+ expect { provider.check_auth }.to raise_error(DPL::Error)
152
+ end
153
+ end
154
+
155
+ describe "#push_app" do
156
+ example "When Release Exists but has no Files" do
157
+ allow_message_expectations_on_nil
158
+
159
+ provider.options.update(:file => ["test/foo.bar", "bar.txt"])
160
+
161
+ allow(provider).to receive(:releases).and_return([""])
162
+ allow(provider).to receive(:get_tag).and_return("v0.0.0")
163
+
164
+ provider.releases.map do |release|
165
+ allow(release).to receive(:tag_name).and_return("v0.0.0")
166
+ allow(release).to receive(:rels).and_return({:self => nil})
167
+ allow(release.rels[:self]).to receive(:href)
168
+ end
169
+
170
+ allow(provider.api).to receive(:release)
171
+ allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
172
+ allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => [""]})
173
+ allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([])
174
+
175
+ expect(provider.api).to receive(:upload_asset).with(anything, "test/foo.bar", {:name=>"foo.bar", :content_type=>"application/octet-stream"})
176
+ expect(provider.api).to receive(:upload_asset).with(anything, "bar.txt", {:name=>"bar.txt", :content_type=>"text/plain"})
177
+ expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => false))
178
+
179
+ provider.push_app
180
+ end
181
+
182
+ example "When Release Exists and has Files" do
183
+ allow_message_expectations_on_nil
184
+
185
+ provider.options.update(:file => ["test/foo.bar", "bar.txt"])
186
+
187
+ allow(provider).to receive(:releases).and_return([""])
188
+ allow(provider).to receive(:get_tag).and_return("v0.0.0")
189
+
190
+ provider.releases.map do |release|
191
+ allow(release).to receive(:tag_name).and_return("v0.0.0")
192
+ allow(release).to receive(:rels).and_return({:self => nil})
193
+ allow(release.rels[:self]).to receive(:href)
194
+ end
195
+
196
+ allow(provider.api).to receive(:release)
197
+ allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
198
+ allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => [""]})
199
+ allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([double(:name => "foo.bar", :url => 'foo-bar-url'), double(:name => "foo.foo", :url => 'foo-foo-url')])
200
+
201
+ expect(provider.api).to receive(:upload_asset).with(anything, "bar.txt", {:name=>"bar.txt", :content_type=>"text/plain"})
202
+ expect(provider).to receive(:log).with("foo.bar already exists, skipping.")
203
+ expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => false))
204
+
205
+ provider.push_app
206
+ end
207
+
208
+ example "When Release Exists and has Files but overwrite flag is true" do
209
+ allow_message_expectations_on_nil
210
+
211
+ provider.options.update(:file => ["exists.txt"])
212
+ provider.options.update(:overwrite => true)
213
+
214
+ allow(provider).to receive(:releases).and_return([""])
215
+ allow(provider).to receive(:get_tag).and_return("v0.0.0")
216
+
217
+ provider.releases.map do |release|
218
+ allow(release).to receive(:tag_name).and_return("v0.0.0")
219
+ allow(release).to receive(:rels).and_return({:self => nil})
220
+ allow(release.rels[:self]).to receive(:href)
221
+ end
222
+
223
+ allow(provider.api).to receive(:release)
224
+ allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
225
+ allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => [""]})
226
+ allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([double(:name => "exists.txt", :url => "release-url")])
227
+
228
+ expect(provider.api).to receive(:delete_release_asset).with("release-url").and_return(true)
229
+ expect(provider.api).to receive(:upload_asset).with(anything, "exists.txt", {:name=>"exists.txt", :content_type=>"text/plain"})
230
+ expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => false))
231
+
232
+ provider.push_app
233
+ end
234
+
235
+ example "When Release Doesn't Exist" do
236
+ allow_message_expectations_on_nil
237
+
238
+ provider.options.update(:file => ["test/foo.bar", "bar.txt"])
239
+
240
+ allow(provider).to receive(:releases).and_return([""])
241
+
242
+ provider.releases.map do |release|
243
+ allow(release).to receive(:tag_name).and_return("foo")
244
+ allow(release).to receive(:rels).and_return({:self => nil})
245
+ allow(release.rels[:self]).to receive(:href)
246
+ end
247
+
248
+ allow(provider.api).to receive(:create_release)
249
+ allow(provider.api.create_release).to receive(:rels).and_return({:self => nil})
250
+ allow(provider.api.create_release.rels[:slef]).to receive(:href)
251
+
252
+ allow(provider.api).to receive(:release)
253
+ allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
254
+ allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => nil})
255
+ allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([])
256
+
257
+ expect(provider.api).to receive(:upload_asset).with(anything, "test/foo.bar", {:name=>"foo.bar", :content_type=>"application/octet-stream"})
258
+ expect(provider.api).to receive(:upload_asset).with(anything, "bar.txt", {:name=>"bar.txt", :content_type=>"text/plain"})
259
+ expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => false))
260
+
261
+ provider.push_app
262
+ end
263
+
264
+ example "With Release Number" do
265
+ allow_message_expectations_on_nil
266
+
267
+ provider.options.update(:file => ["bar.txt"])
268
+ provider.options.update(:release_number => "1234")
269
+
270
+ allow(provider).to receive(:slug).and_return("foo/bar")
271
+
272
+ allow(provider.api).to receive(:release)
273
+ allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
274
+ allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => nil})
275
+ allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([])
276
+
277
+ expect(provider.api).to receive(:upload_asset).with("https://api.github.com/repos/foo/bar/releases/1234", "bar.txt", {:name=>"bar.txt", :content_type=>"text/plain"})
278
+ expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => false))
279
+
280
+ provider.push_app
281
+ end
282
+
283
+ example "When draft is true" do
284
+ allow_message_expectations_on_nil
285
+
286
+ provider.options.update(:file => ["bar.txt"])
287
+ provider.options.update(:release_number => "1234")
288
+ provider.options.update(:draft => true)
289
+
290
+ allow(provider).to receive(:slug).and_return("foo/bar")
291
+
292
+ allow(provider.api).to receive(:release)
293
+ allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
294
+ allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => nil})
295
+ allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([])
296
+
297
+ expect(provider.api).to receive(:upload_asset).with("https://api.github.com/repos/foo/bar/releases/1234", "bar.txt", {:name=>"bar.txt", :content_type=>"text/plain"})
298
+ expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => true))
299
+
300
+ provider.push_app
301
+ end
302
+ end
303
+ end
@@ -0,0 +1,106 @@
1
+ require 'spec_helper'
2
+ require 'rubygems'
3
+ require 'gems'
4
+ require 'dpl/provider/rubygems'
5
+
6
+ describe DPL::Provider::RubyGems do
7
+ subject :provider do
8
+ described_class.new(DummyContext.new, :app => 'example', :api_key => 'foo')
9
+ end
10
+
11
+ describe "#api" do
12
+ example "with an api key" do
13
+ expect(::Gems).to receive(:key=).with('foo')
14
+ provider.setup_auth
15
+ end
16
+
17
+ example "with a username and password" do
18
+ provider.options.update(:user => 'test', :password => 'blah')
19
+ provider.options.delete(:api_key)
20
+ expect(::Gems).to receive(:username=).with('test')
21
+ expect(::Gems).to receive(:password=).with('blah')
22
+ provider.setup_auth
23
+ end
24
+ end
25
+
26
+ describe "#check_auth" do
27
+ example do
28
+ provider.options.update(:user => 'test', :password => 'blah')
29
+ provider.options.delete(:api_key)
30
+ expect(provider).to receive(:log).with("Authenticated with username test")
31
+ provider.check_auth
32
+ end
33
+ end
34
+
35
+ describe "#check_app" do
36
+ example do
37
+ expect(::Gems).to receive(:info).with('example').and_return({'name' => 'example'})
38
+ expect(provider).to receive(:log).with("Looking up gem example")
39
+ expect(provider).to receive(:log).with("Found gem example")
40
+ provider.check_app
41
+ end
42
+ end
43
+
44
+ describe "#push_app" do
45
+ after(:each) do
46
+ expect(File).to receive(:new).with('File').and_return('Test file')
47
+ expect(provider).to receive(:log).with('Yes!')
48
+ provider.push_app
49
+ end
50
+
51
+ example "with options[:app]" do
52
+ provider.options.update(:app => 'example')
53
+ expect(provider.context).to receive(:shell).with("gem build example.gemspec")
54
+ expect(Dir).to receive(:glob).with('example-*.gem').and_yield('File')
55
+ expect(::Gems).to receive(:push).with('Test file').and_return('Yes!')
56
+ end
57
+
58
+ example "with options[:gem]" do
59
+ provider.options.update(:gem => 'example-gem')
60
+ expect(provider.context).to receive(:shell).with("gem build example-gem.gemspec")
61
+ expect(Dir).to receive(:glob).with('example-gem-*.gem').and_yield('File')
62
+ expect(::Gems).to receive(:push).with('Test file').and_return('Yes!')
63
+ end
64
+
65
+ example "with options[:gemspec]" do
66
+ provider.options.update(:gemspec => 'blah.gemspec')
67
+ expect(provider.context).to receive(:shell).with("gem build blah.gemspec")
68
+ expect(Dir).to receive(:glob).with('blah-*.gem').and_yield('File')
69
+ expect(::Gems).to receive(:push).with('Test file').and_return('Yes!')
70
+ end
71
+
72
+ example "with options[:host]" do
73
+ provider.options.update(:host => 'http://example.com')
74
+ expect(provider.context).to receive(:shell).with("gem build example.gemspec")
75
+ expect(Dir).to receive(:glob).with('example-*.gem').and_yield('File')
76
+ expect(::Gems).to receive(:push).with('Test file', host='http://example.com').and_return('Yes!')
77
+ end
78
+ end
79
+
80
+ describe "#setup_gem" do
81
+ example "with options[:gem] and options[:app] set" do
82
+ provider.options.update(:gem => 'test', :app => 'blah')
83
+ provider.setup_gem
84
+ expect(provider.options[:gem]).to eq('test')
85
+ end
86
+
87
+ example "with options[:app] set" do
88
+ provider.options.update(:app => 'foo')
89
+ provider.setup_gem
90
+ expect(provider.options[:gem]).to eq('foo')
91
+ end
92
+
93
+ example "with options[:gem] set" do
94
+ provider.options.update(:gem => 'bar')
95
+ provider.setup_gem
96
+ expect(provider.options[:gem]).to eq('bar')
97
+ end
98
+ end
99
+
100
+ describe "#gemspec" do
101
+ example do
102
+ provider.options.update(:gemspec => 'test.gemspec')
103
+ expect(provider.gemspec).to eq('test')
104
+ end
105
+ end
106
+ end