fog-core 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +2 -0
  3. data/.github/dependabot.yml +2 -4
  4. data/.github/workflows/ci.yml +32 -0
  5. data/.rubocop.yml +1 -1
  6. data/README.md +2 -1
  7. data/SECURITY.md +6 -0
  8. data/changelog.md +12 -0
  9. data/fog-core.gemspec +1 -1
  10. data/lib/fog/compute.rb +1 -1
  11. data/lib/fog/core/mock.rb +1 -1
  12. data/lib/fog/core/provider.rb +1 -1
  13. data/lib/fog/core/service.rb +1 -1
  14. data/lib/fog/core/version.rb +1 -1
  15. data/lib/fog/core.rb +0 -1
  16. data/lib/fog/formatador.rb +3 -3
  17. data/lib/fog/storage.rb +0 -1
  18. data/lib/tasks/test_task.rb +2 -3
  19. metadata +5 -31
  20. data/.github/workflows/ruby.yml +0 -18
  21. data/.github/workflows/stale.yml +0 -9
  22. data/spec/compute/models/server_spec.rb +0 -229
  23. data/spec/compute_spec.rb +0 -95
  24. data/spec/connection_spec.rb +0 -107
  25. data/spec/core/cache_spec.rb +0 -227
  26. data/spec/core/collection_spec.rb +0 -24
  27. data/spec/core/model_spec.rb +0 -69
  28. data/spec/core/stringify_keys_spec.rb +0 -38
  29. data/spec/core/whitelist_keys_spec.rb +0 -36
  30. data/spec/credentials_spec.rb +0 -88
  31. data/spec/current_machine_spec.rb +0 -36
  32. data/spec/fake_app/fake_service.rb +0 -18
  33. data/spec/fake_app/models/collection.rb +0 -5
  34. data/spec/fake_app/models/model.rb +0 -2
  35. data/spec/fake_app/requests/request.rb +0 -11
  36. data/spec/fog_attribute_spec.rb +0 -569
  37. data/spec/formatador_spec.rb +0 -154
  38. data/spec/identity_spec.rb +0 -95
  39. data/spec/mocking_spec.rb +0 -84
  40. data/spec/service_spec.rb +0 -201
  41. data/spec/spec_helper.rb +0 -14
  42. data/spec/storage_spec.rb +0 -112
  43. data/spec/test_helpers/formats_helper_spec.rb +0 -121
  44. data/spec/test_helpers/schema_validator_spec.rb +0 -101
  45. data/spec/timeout_spec.rb +0 -20
  46. data/spec/utils_spec.rb +0 -29
  47. data/spec/uuid_spec.rb +0 -11
  48. data/spec/wait_for_spec.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db8a9288ea6ab96cad44beb5929626aa0a46471f97eb59847b28959e6da86c24
4
- data.tar.gz: c3511cc0aa13da61f238f973aea137942c59c6b7965153e179d3b3f5929720cc
3
+ metadata.gz: 4b81d32f406966d1e603bd7da20eb75a74bc8761f7187177a03d863b20585c7b
4
+ data.tar.gz: df024a0491295236bbde204c8d2b17c776c185d6c6ec8276fe4244b442a2329b
5
5
  SHA512:
6
- metadata.gz: 9b283a4a4236e3bc1fd9d42322d8fa30992f3f3fc76bd5d117d7dc04b22caa3c835e39bc236e8160d860a373e7f370660f6f3e13cbb34caf1d1767e56346c3cf
7
- data.tar.gz: db4ed981ea6177822599954a389865959d56e5aab1421c4161f9f33b090e73d28966b6c2a16f56ba724d99cb9216460ce0fd0d4a72a48d5f2cbb7df4fd8fd6a5
6
+ metadata.gz: 7fba41ef8c39b0832c6371df52e9827a77094cf66976d97043f0a6d5bff38b337033eef7d7dcbdb330633c156d7ab58d67b1b15c9995d7a113f16169b7a4944a
7
+ data.tar.gz: e6770dccfca56f1ff303340d1160453bcb3b87b0b330a52e74361c8b0cf7410ceed5c663cdf56bb94a35134bec3229128abcc29f51b7526592b6c933f687c6b9
@@ -0,0 +1,2 @@
1
+ github: geemus
2
+ tidelift: rubygems/fog-core
@@ -3,10 +3,8 @@ updates:
3
3
  - package-ecosystem: "bundler"
4
4
  directory: "/"
5
5
  schedule:
6
- interval: "daily"
7
- allow:
8
- - dependency-type: "all" # update both gemspec and lock
6
+ interval: "weekly"
9
7
  - package-ecosystem: "github-actions"
10
8
  directory: "/"
11
9
  schedule:
12
- interval: "daily"
10
+ interval: "weekly"
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+ schedule:
9
+ - cron: '0 0 * * 1' # At 00:00 on Monday.
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ test:
16
+
17
+ runs-on: ubuntu-latest
18
+
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ['3.0', '3.1', '3.2', '3.3', 'head']
22
+ continue-on-error: ${{ matrix.ruby-version == 'head' }}
23
+
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
31
+ - name: Run tests
32
+ run: bundle exec rake RUBYOPT="--enable-frozen-string-literal"
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.0
4
+ TargetRubyVersion: 3.0
5
5
  NewCops: enable
6
6
 
7
7
  require:
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  Shared classes and tests for fog providers and services.
4
4
 
5
- [![Build Status](https://github.com/fog/fog-core/actions/workflows/ruby.yml/badge.svg)](https://github.com/fog/fog-core/actions/workflows/ruby.yml)
5
+ [![Build Status](https://github.com/fog/fog-core/actions/workflows/ci.yml/badge.svg)](https://github.com/fog/fog-core/actions/workflows/ci.yml)
6
+ [![Gem Version](https://badge.fury.io/rb/fog-core.svg)](https://rubygems.org/gems/fog-core)
6
7
 
7
8
  ## Ruby version
8
9
 
data/SECURITY.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Security contact information
2
+
3
+ To report a security vulnerability, please contact
4
+ [Tidelift security](https://tidelift.com/security).
5
+
6
+ Tidelift will coordinate the fix and disclosure.
data/changelog.md CHANGED
@@ -1,3 +1,15 @@
1
+ 2.5.0 08/02/2024
2
+ ==========================================================
3
+
4
+ - drop spec files from gem package
5
+ - fix 3.4+ ruby issues (string literals and base64)
6
+ - bump rubocop target
7
+ - remove stale actions
8
+ - fixes to ci
9
+ - add security policy
10
+ - add gem version badge
11
+ - add funding info
12
+
1
13
  2.4.0 01/03/2024
2
14
  ==========================================================
3
15
 
data/fog-core.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/fog/fog-core"
15
15
  spec.license = "MIT"
16
16
 
17
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).reject {|f| f.start_with? ('spec/') }
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
data/lib/fog/compute.rb CHANGED
@@ -29,7 +29,7 @@ module Fog
29
29
  Fog::Compute::DigitalOcean.new(attributes)
30
30
  end
31
31
  else
32
- super(orig_attributes)
32
+ super
33
33
  end
34
34
  end
35
35
 
data/lib/fog/core/mock.rb CHANGED
@@ -81,7 +81,7 @@ module Fog
81
81
  end
82
82
 
83
83
  def self.random_selection(characters, length)
84
- selection = ""
84
+ selection = +""
85
85
  length.times do
86
86
  position = rand(characters.length)
87
87
  selection << characters[position..position]
@@ -18,7 +18,7 @@ module Fog
18
18
  private
19
19
 
20
20
  def underscore_name(string)
21
- string.gsub(/::/, "/")
21
+ string.gsub("::", "/")
22
22
  .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
23
23
  .gsub(/([a-z\d])([A-Z])/,'\1_\2')
24
24
  .tr("-", "_")
@@ -212,7 +212,7 @@ module Fog
212
212
  @secrets ||= []
213
213
  else
214
214
  args.reduce(secrets) do |secrets, secret|
215
- secrets << "@#{secret}".to_sym
215
+ secrets << :"@#{secret}"
216
216
  end
217
217
  end
218
218
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Core
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.5.0".freeze
4
4
  end
5
5
  end
data/lib/fog/core.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # external core dependencies
2
- require "base64"
3
2
  require "cgi"
4
3
  require "uri"
5
4
  require "excon"
@@ -10,7 +10,7 @@ module Fog
10
10
  end
11
11
 
12
12
  def self.format(object, opts = { include_nested: true })
13
- string = init_string(object)
13
+ string = +init_string(object)
14
14
  indent { string << object_string(object, opts) }
15
15
  string << "#{indentation}>"
16
16
  end
@@ -48,7 +48,7 @@ module Fog
48
48
  end
49
49
 
50
50
  def self.object_string(object, opts)
51
- string = attribute_string(object).to_s
51
+ string = +attribute_string(object).to_s
52
52
  string << nested_objects_string(object).to_s if opts[:include_nested]
53
53
  string
54
54
  end
@@ -68,7 +68,7 @@ module Fog
68
68
  return nested if object.respond_to?(:empty) and object.empty?
69
69
  return nested unless object.is_a?(Enumerable)
70
70
 
71
- nested = "#{indentation}[\n"
71
+ nested = +"#{indentation}[\n"
72
72
  indent { nested << indentation + inspect_object(object) }
73
73
  nested << "#{indentation}\n#{indentation}]\n"
74
74
  end
data/lib/fog/storage.rb CHANGED
@@ -59,7 +59,6 @@ module Fog
59
59
  headers: {
60
60
  "Content-Length" => get_body_size(data),
61
61
  "Content-Type" => get_content_type(data)
62
- # "Content-MD5" => Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
63
62
  }
64
63
  }
65
64
  end
@@ -22,10 +22,9 @@ module Fog
22
22
  def tests(mocked)
23
23
  Fog::Formatador.display_line
24
24
  start = Time.now.to_i
25
- threads = []
26
25
  Thread.main[:results] = []
27
- Fog.providers.each do |key, value|
28
- threads << Thread.new do
26
+ threads = Fog.providers.map do |key, value|
27
+ Thread.new do
29
28
  Thread.main[:results] << {
30
29
  provider: value,
31
30
  success: sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Light
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-03 00:00:00.000000000 Z
12
+ date: 2024-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -221,9 +221,9 @@ executables: []
221
221
  extensions: []
222
222
  extra_rdoc_files: []
223
223
  files:
224
+ - ".github/FUNDING.yml"
224
225
  - ".github/dependabot.yml"
225
- - ".github/workflows/ruby.yml"
226
- - ".github/workflows/stale.yml"
226
+ - ".github/workflows/ci.yml"
227
227
  - ".gitignore"
228
228
  - ".rubocop.yml"
229
229
  - ".rubocop_todo.yml"
@@ -233,6 +233,7 @@ files:
233
233
  - LICENSE.md
234
234
  - README.md
235
235
  - Rakefile
236
+ - SECURITY.md
236
237
  - changelog.md
237
238
  - fog-core.gemspec
238
239
  - lib/fog/account.rb
@@ -312,33 +313,6 @@ files:
312
313
  - lib/fog/volume.rb
313
314
  - lib/fog/vpn.rb
314
315
  - lib/tasks/test_task.rb
315
- - spec/compute/models/server_spec.rb
316
- - spec/compute_spec.rb
317
- - spec/connection_spec.rb
318
- - spec/core/cache_spec.rb
319
- - spec/core/collection_spec.rb
320
- - spec/core/model_spec.rb
321
- - spec/core/stringify_keys_spec.rb
322
- - spec/core/whitelist_keys_spec.rb
323
- - spec/credentials_spec.rb
324
- - spec/current_machine_spec.rb
325
- - spec/fake_app/fake_service.rb
326
- - spec/fake_app/models/collection.rb
327
- - spec/fake_app/models/model.rb
328
- - spec/fake_app/requests/request.rb
329
- - spec/fog_attribute_spec.rb
330
- - spec/formatador_spec.rb
331
- - spec/identity_spec.rb
332
- - spec/mocking_spec.rb
333
- - spec/service_spec.rb
334
- - spec/spec_helper.rb
335
- - spec/storage_spec.rb
336
- - spec/test_helpers/formats_helper_spec.rb
337
- - spec/test_helpers/schema_validator_spec.rb
338
- - spec/timeout_spec.rb
339
- - spec/utils_spec.rb
340
- - spec/uuid_spec.rb
341
- - spec/wait_for_spec.rb
342
316
  homepage: https://github.com/fog/fog-core
343
317
  licenses:
344
318
  - MIT
@@ -1,18 +0,0 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches: [ master ]
13
- pull_request:
14
- branches: [ master ]
15
-
16
- jobs:
17
- test:
18
- uses: fog/.github/.github/workflows/ruby.yml@v1.3.0
@@ -1,9 +0,0 @@
1
- name: Mark stale issues and pull requests
2
-
3
- on:
4
- schedule:
5
- - cron: "30 1 * * *"
6
-
7
- jobs:
8
- stale:
9
- uses: fog/.github/.github/workflows/stale.yml@v1.3.0
@@ -1,229 +0,0 @@
1
- require "spec_helper"
2
- require "fog/compute/models/server"
3
-
4
- describe Fog::Compute::Server do
5
- before do
6
- @server = Fog::Compute::Server.new
7
- end
8
-
9
- describe "#sshable?" do
10
- describe "when the server is not ready" do
11
- it "is false" do
12
- @server.stub(:ready?, false) do
13
- refute @server.sshable?
14
- end
15
- end
16
- end
17
-
18
- describe "when the server is ready" do
19
- describe "when the ssh_ip_address is nil" do
20
- it "is false" do
21
- @server.stub(:ready?, true) do
22
- @server.stub(:ssh_ip_address, nil) do
23
- refute @server.sshable?
24
- end
25
- end
26
- end
27
- end
28
-
29
- describe "when the ssh_ip_address exists" do
30
- # Define these constants which would be imported by net-ssh once loaded
31
- module Net
32
- module SSH
33
- class AuthenticationFailed < RuntimeError
34
- end
35
-
36
- class Disconnect < RuntimeError
37
- end
38
- end
39
- end
40
-
41
- describe "and ssh times out" do
42
- it "is false" do
43
- @server.stub(:ready?, true) do
44
- @server.stub(:ssh_ip_address, "10.0.0.1") do
45
- raises_timeout = lambda { |_time| raise Timeout::Error.new }
46
- Timeout.stub(:timeout, raises_timeout) do
47
- refute @server.sshable?
48
- end
49
- end
50
- end
51
- end
52
- end
53
-
54
- describe "and it raises Net::SSH::AuthenticationFailed" do
55
- it "is false" do
56
- @server.stub(:ready?, true) do
57
- @server.stub(:ssh_ip_address, "10.0.0.1") do
58
- raise_error = lambda { |_cmd, _options={}| raise Net::SSH::AuthenticationFailed.new }
59
- @server.stub(:ssh, raise_error) do
60
- refute @server.sshable?
61
- end
62
- end
63
- end
64
- end
65
-
66
- it "resets SSH timeout" do
67
- @server.instance_variable_set(:@sshable_timeout, 8)
68
- @server.stub(:ready?, true) do
69
- @server.stub(:ssh_ip_address, "10.0.0.1") do
70
- raise_error = lambda { |_cmd, _options={}| raise Net::SSH::AuthenticationFailed.new }
71
- @server.stub(:ssh, raise_error) do
72
- @server.sshable?
73
- assert_nil @server.instance_variable_get(:@sshable_timeout), nil
74
- end
75
- end
76
- end
77
- end
78
- end
79
-
80
- describe "and it raises Net::SSH::Disconnect" do
81
- it "is false" do
82
- @server.stub(:ready?, true) do
83
- @server.stub(:ssh_ip_address, "10.0.0.1") do
84
- raise_error = lambda { |_cmd, _options={}| raise Net::SSH::Disconnect.new }
85
- @server.stub(:ssh, raise_error) do
86
- refute @server.sshable?
87
- end
88
- end
89
- end
90
- end
91
-
92
- it "resets SSH timeout" do
93
- @server.instance_variable_set(:@sshable_timeout, 8)
94
- @server.stub(:ready?, true) do
95
- @server.stub(:ssh_ip_address, "10.0.0.1") do
96
- raise_error = lambda { |_cmd, _options={}| raise Net::SSH::Disconnect.new }
97
- @server.stub(:ssh, raise_error) do
98
- @server.sshable?
99
- assert_nil @server.instance_variable_get(:@sshable_timeout), nil
100
- end
101
- end
102
- end
103
- end
104
- end
105
-
106
- describe "and it raises SystemCallError" do
107
- it "is false" do
108
- @server.stub(:ready?, true) do
109
- @server.stub(:ssh_ip_address, "10.0.0.1") do
110
- raise_error = lambda { |_cmd, _options={}| raise SystemCallError.new("message, 0") }
111
- @server.stub(:ssh, raise_error) do
112
- refute @server.sshable?
113
- end
114
- end
115
- end
116
- end
117
-
118
- it "does not increase SSH timeout" do
119
- @server.stub(:ready?, true) do
120
- @server.stub(:ssh_ip_address, "10.0.0.1") do
121
- raise_error = lambda { |_cmd, _options={}| raise SystemCallError.new("message, 0") }
122
- @server.stub(:ssh, raise_error) do
123
- @server.sshable?
124
- assert_equal @server.instance_variable_get(:@sshable_timeout), 8
125
- end
126
- end
127
- end
128
- end
129
- end
130
-
131
- describe "and ssh completes within the designated timeout" do
132
- it "is true" do
133
- @server.stub(:ready?, true) do
134
- @server.stub(:ssh_ip_address, "10.0.0.1") do
135
- @server.stub(:ssh, "datum") do
136
- assert @server.sshable?
137
- end
138
- end
139
- end
140
- end
141
- end
142
-
143
- describe "when called successively" do
144
- describe "and ssh times out" do
145
- it "increases the timeout factor by 1.5" do
146
- @server.stub(:ready?, true) do
147
- @server.stub(:ssh_ip_address, "10.0.0.1") do
148
- raises_timeout = lambda do |time|
149
- assert(time == 8)
150
- raise Timeout::Error.new
151
- end
152
- Timeout.stub(:timeout, raises_timeout) do
153
- refute @server.sshable?
154
- end
155
-
156
- raises_timeout = lambda do |time|
157
- assert_equal(12, time)
158
- raise Timeout::Error.new
159
- end
160
- Timeout.stub(:timeout, raises_timeout) do
161
- refute @server.sshable?
162
- end
163
- end
164
- end
165
- end
166
-
167
- it "does not increase timeout beyond 60s" do
168
- @server.stub(:ready?, true) do
169
- @server.stub(:ssh_ip_address, "10.0.0.1") do
170
- raises_timeout = lambda { |_time| raise Timeout::Error.new }
171
- Timeout.stub(:timeout, raises_timeout) do
172
- 5.times { refute @server.sshable? }
173
- end
174
-
175
- raises_timeout = lambda do |time|
176
- assert_equal(60, time)
177
- raise Timeout::Error.new
178
- end
179
- Timeout.stub(:timeout, raises_timeout) do
180
- refute @server.sshable?
181
- end
182
-
183
- raises_timeout = lambda do |time|
184
- assert_equal(60, time)
185
- raise Timeout::Error.new
186
- end
187
- Timeout.stub(:timeout, raises_timeout) do
188
- refute @server.sshable?
189
- end
190
- end
191
- end
192
- end
193
-
194
- describe "when ssh eventually succeeds" do
195
- it "resets the timeout to the initial value" do
196
- @server.stub(:ready?, true) do
197
- @server.stub(:ssh_ip_address, "10.0.0.1") do
198
- raises_timeout = lambda do |time|
199
- assert(time == 8)
200
- raise Timeout::Error.new
201
- end
202
- Timeout.stub(:timeout, raises_timeout) do
203
- refute @server.sshable?
204
- end
205
-
206
- @server.stub(:ssh, "datum") do
207
- assert @server.sshable?
208
- end
209
-
210
- raises_timeout = lambda do |time|
211
- assert_equal(8, time)
212
- raise Timeout::Error.new
213
- end
214
- Timeout.stub(:timeout, raises_timeout) do
215
- refute @server.sshable?
216
- end
217
- end
218
- end
219
- end
220
- end
221
-
222
- end
223
- end
224
-
225
- end
226
- end
227
-
228
- end
229
- end
data/spec/compute_spec.rb DELETED
@@ -1,95 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Fog
4
- module Compute
5
- def self.require(*_args); end
6
- end
7
- end
8
-
9
- describe "Fog::Compute" do
10
- describe "#new" do
11
- module Fog
12
- module TheRightWay
13
- class Compute
14
- def initialize(_args); end
15
- end
16
- end
17
- end
18
-
19
- module Fog
20
- module TheRightWay
21
- extend Provider
22
- service(:compute, "Compute")
23
- end
24
- end
25
-
26
- it "instantiates an instance of Fog::Compute::<Provider> from the :provider keyword arg" do
27
- compute = Fog::Compute.new(provider: :therightway)
28
- assert_instance_of(Fog::TheRightWay::Compute, compute)
29
- end
30
-
31
- module Fog
32
- module Compute
33
- class TheWrongWay
34
- def initialize(_args); end
35
- end
36
- end
37
- end
38
-
39
- module Fog
40
- module TheWrongWay
41
- extend Provider
42
- service(:compute, "Compute")
43
- end
44
- end
45
-
46
- it "instantiates an instance of Fog::<Provider>::Compute from the :provider keyword arg" do
47
- compute = Fog::Compute.new(provider: :thewrongway)
48
- assert_instance_of(Fog::Compute::TheWrongWay, compute)
49
- end
50
-
51
- module Fog
52
- module BothWays
53
- class Compute
54
- attr_reader :args
55
- def initialize(args)
56
- @args = args
57
- end
58
- end
59
- end
60
- end
61
-
62
- module Fog
63
- module Compute
64
- class BothWays
65
- def initialize(_args); end
66
- end
67
- end
68
- end
69
-
70
- module Fog
71
- module BothWays
72
- extend Provider
73
- service(:compute, "Compute")
74
- end
75
- end
76
-
77
- describe "when both Fog::Compute::<Provider> and Fog::<Provider>::Compute exist" do
78
- it "prefers Fog::<Provider>::Compute" do
79
- compute = Fog::Compute.new(provider: :bothways)
80
- assert_instance_of(Fog::BothWays::Compute, compute)
81
- end
82
- end
83
-
84
- it "passes the supplied keyword args less :provider to Fog::Compute::<Provider>#new" do
85
- compute = Fog::Compute.new(provider: :bothways, extra: :stuff)
86
- assert_equal({ extra: :stuff }, compute.args)
87
- end
88
-
89
- it "raises ArgumentError when given a :provider where a Fog::Compute::Provider that does not exist" do
90
- assert_raises(ArgumentError) do
91
- Fog::Compute.new(provider: :wat)
92
- end
93
- end
94
- end
95
- end