fog-core 2.1.0 → 2.4.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.
Files changed (78) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +12 -0
  3. data/.github/workflows/ruby.yml +18 -0
  4. data/.github/workflows/stale.yml +9 -0
  5. data/.rubocop.yml +16 -12
  6. data/.rubocop_todo.yml +724 -0
  7. data/CONTRIBUTING.md +5 -1
  8. data/Gemfile +1 -1
  9. data/README.md +1 -1
  10. data/Rakefile +2 -14
  11. data/changelog.md +224 -141
  12. data/fog-core.gemspec +11 -8
  13. data/lib/fog/account.rb +0 -16
  14. data/lib/fog/billing.rb +0 -11
  15. data/lib/fog/compute/models/server.rb +7 -3
  16. data/lib/fog/compute.rb +2 -24
  17. data/lib/fog/core/association.rb +1 -0
  18. data/lib/fog/core/attributes/default.rb +7 -0
  19. data/lib/fog/core/attributes.rb +42 -5
  20. data/lib/fog/core/cache.rb +58 -55
  21. data/lib/fog/core/collection.rb +9 -3
  22. data/lib/fog/core/connection.rb +4 -6
  23. data/lib/fog/core/current_machine.rb +1 -1
  24. data/lib/fog/core/errors.rb +1 -1
  25. data/lib/fog/core/logger.rb +5 -2
  26. data/lib/fog/core/mock.rb +6 -1
  27. data/lib/fog/core/model.rb +34 -5
  28. data/lib/fog/core/provider.rb +37 -4
  29. data/lib/fog/core/scp.rb +16 -11
  30. data/lib/fog/core/service.rb +4 -4
  31. data/lib/fog/core/services_mixin.rb +62 -10
  32. data/lib/fog/core/ssh.rb +49 -25
  33. data/lib/fog/core/stringify_keys.rb +0 -2
  34. data/lib/fog/core/time.rb +2 -2
  35. data/lib/fog/core/uuid.rb +2 -8
  36. data/lib/fog/core/version.rb +1 -1
  37. data/lib/fog/core/wait_for.rb +2 -1
  38. data/lib/fog/core/wait_for_defaults.rb +2 -0
  39. data/lib/fog/core.rb +57 -58
  40. data/lib/fog/dns.rb +0 -11
  41. data/lib/fog/formatador.rb +7 -6
  42. data/lib/fog/monitoring.rb +0 -11
  43. data/lib/fog/network.rb +0 -12
  44. data/lib/fog/schema/data_validator.rb +1 -0
  45. data/lib/fog/storage.rb +15 -29
  46. data/lib/fog/support.rb +0 -12
  47. data/lib/fog/test_helpers/collection_helper.rb +2 -0
  48. data/lib/fog/test_helpers/formats_helper.rb +2 -2
  49. data/lib/fog/test_helpers/helper.rb +3 -3
  50. data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
  51. data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
  52. data/lib/fog/test_helpers/mock_helper.rb +84 -84
  53. data/lib/fog/test_helpers/succeeds_helper.rb +2 -2
  54. data/lib/fog/test_helpers/types_helper.rb +1 -0
  55. data/lib/fog/vpn.rb +0 -12
  56. data/lib/tasks/test_task.rb +2 -2
  57. data/spec/compute/models/server_spec.rb +7 -7
  58. data/spec/compute_spec.rb +33 -33
  59. data/spec/connection_spec.rb +11 -9
  60. data/spec/core/cache_spec.rb +52 -16
  61. data/spec/core/collection_spec.rb +24 -0
  62. data/spec/core/model_spec.rb +36 -3
  63. data/spec/core/stringify_keys_spec.rb +3 -3
  64. data/spec/core/whitelist_keys_spec.rb +2 -2
  65. data/spec/current_machine_spec.rb +2 -2
  66. data/spec/fog_attribute_spec.rb +183 -163
  67. data/spec/formatador_spec.rb +7 -7
  68. data/spec/identity_spec.rb +32 -32
  69. data/spec/mocking_spec.rb +3 -3
  70. data/spec/service_spec.rb +19 -19
  71. data/spec/spec_helper.rb +3 -8
  72. data/spec/storage_spec.rb +33 -35
  73. data/spec/test_helpers/formats_helper_spec.rb +8 -8
  74. data/spec/test_helpers/schema_validator_spec.rb +8 -8
  75. data/spec/utils_spec.rb +6 -6
  76. data/spec/wait_for_spec.rb +2 -2
  77. metadata +57 -59
  78. data/.travis.yml +0 -39
@@ -106,6 +106,7 @@ module Fog
106
106
  case validator
107
107
  when Array
108
108
  return false if value.is_a?(Hash)
109
+
109
110
  value.respond_to?(:all?) && value.all? { |x| validate_value(validator[0], x, options) }
110
111
  when Symbol
111
112
  value.respond_to? validator
data/lib/fog/storage.rb CHANGED
@@ -1,28 +1,14 @@
1
1
  begin
2
2
  # Use mime/types/columnar if available, for reduced memory usage
3
- require 'mime/types/columnar'
3
+ require "mime/types/columnar"
4
4
  rescue LoadError
5
- require 'mime/types'
5
+ require "mime/types"
6
6
  end
7
7
 
8
8
  module Fog
9
9
  module Storage
10
10
  extend Fog::ServicesMixin
11
11
 
12
- def self.new(orig_attributes)
13
- attributes = orig_attributes.dup # prevent delete from having side effects
14
- case attributes.delete(:provider).to_s.downcase.to_sym
15
- when :internetarchive
16
- require "fog/internet_archive/storage"
17
- Fog::Storage::InternetArchive.new(attributes)
18
- when :stormondemand
19
- require "fog/storage/storm_on_demand"
20
- Fog::Storage::StormOnDemand.new(attributes)
21
- else
22
- super(orig_attributes)
23
- end
24
- end
25
-
26
12
  def self.directories
27
13
  directories = []
28
14
  providers.each do |provider|
@@ -38,18 +24,18 @@ module Fog
38
24
  if body.respond_to?(:encoding)
39
25
  original_encoding = body.encoding
40
26
  body = body.dup if body.frozen?
41
- body = body.force_encoding('BINARY')
27
+ body = body.force_encoding("BINARY")
42
28
  end
43
29
 
44
30
  size = if body.respond_to?(:bytesize)
45
- body.bytesize
46
- elsif body.respond_to?(:size)
47
- body.size
48
- elsif body.respond_to?(:stat)
49
- body.stat.size
50
- else
51
- 0
52
- end
31
+ body.bytesize
32
+ elsif body.respond_to?(:size)
33
+ body.size
34
+ elsif body.respond_to?(:stat)
35
+ body.stat.size
36
+ else
37
+ 0
38
+ end
53
39
 
54
40
  if body.respond_to?(:encoding)
55
41
  body.force_encoding(original_encoding)
@@ -69,10 +55,10 @@ module Fog
69
55
 
70
56
  def self.parse_data(data)
71
57
  {
72
- :body => data,
73
- :headers => {
74
- "Content-Length" => get_body_size(data),
75
- "Content-Type" => get_content_type(data)
58
+ body: data,
59
+ headers: {
60
+ "Content-Length" => get_body_size(data),
61
+ "Content-Type" => get_content_type(data)
76
62
  # "Content-MD5" => Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
77
63
  }
78
64
  }
data/lib/fog/support.rb CHANGED
@@ -1,17 +1,5 @@
1
1
  module Fog
2
2
  module Support
3
3
  extend Fog::ServicesMixin
4
-
5
- def self.new(orig_attributes)
6
- attributes = orig_attributes.dup
7
- provider = attributes.delete(:provider).to_s.downcase.to_sym
8
-
9
- if provider == :stormondemand
10
- require "fog/support/storm_on_demand"
11
- Fog::Support::StormOnDemand.new(attributes)
12
- else
13
- super(orig_attributes)
14
- end
15
- end
16
4
  end
17
5
  end
@@ -35,6 +35,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
35
35
 
36
36
  methods.each do |enum_method|
37
37
  next unless collection.respond_to?(enum_method)
38
+
38
39
  tests("##{enum_method}").succeeds do
39
40
  block_called = false
40
41
  collection.send(enum_method) { block_called = true }
@@ -44,6 +45,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
44
45
 
45
46
  %w(max_by min_by).each do |enum_method|
46
47
  next unless collection.respond_to?(enum_method)
48
+
47
49
  tests("##{enum_method}").succeeds do
48
50
  block_called = false
49
51
  collection.send(enum_method) do
@@ -60,9 +60,9 @@ module Shindo
60
60
  def formats(format, strict = true)
61
61
  test("has proper format") do
62
62
  if strict
63
- options = { :allow_extra_keys => false, :allow_optional_rules => true }
63
+ options = { allow_extra_keys: false, allow_optional_rules: true }
64
64
  else
65
- options = { :allow_extra_keys => true, :allow_optional_rules => true }
65
+ options = { allow_extra_keys: true, allow_optional_rules: true }
66
66
  end
67
67
  validator = Fog::Schema::DataValidator.new
68
68
  valid = validator.validate(yield, format, options)
@@ -1,11 +1,11 @@
1
1
  require "excon"
2
2
 
3
- ENV["FOG_RC"] = ENV["FOG_RC"] || File.expand_path("../.fog", __FILE__)
3
+ ENV["FOG_RC"] = ENV["FOG_RC"] || File.expand_path(".fog", __dir__)
4
4
  ENV["FOG_CREDENTIAL"] = ENV["FOG_CREDENTIAL"] || "default"
5
5
 
6
- Excon.defaults.merge!(:debug_request => true, :debug_response => true)
6
+ Excon.defaults.merge!(debug_request: true, debug_response: true)
7
7
 
8
- LOREM = <<HERE
8
+ LOREM = <<HERE.freeze
9
9
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
10
10
  incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
11
11
  nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
@@ -1,6 +1,6 @@
1
1
  require "fog/schema/data_validator"
2
2
 
3
- module MiniTest::Assertions
3
+ module Minitest::Assertions
4
4
  # Compares a hash's structure against a reference schema hash and returns true
5
5
  # when they match. Fog::Schema::Datavalidator is used for the validation.
6
6
  def assert_match_schema(actual, schema, message = nil, options = {})
@@ -1,3 +1,3 @@
1
- module MiniTest::Expectations
1
+ module Minitest::Expectations
2
2
  infect_an_assertion :assert_match_schema, :must_match_schema, :reverse
3
3
  end
@@ -9,91 +9,91 @@ Fog.mock! if ENV["FOG_MOCK"] == "true"
9
9
  # if in mocked mode, fill in some fake credentials for us
10
10
  if Fog.mock?
11
11
  Fog.credentials = {
12
- :aws_access_key_id => "aws_access_key_id",
13
- :aws_secret_access_key => "aws_secret_access_key",
14
- :ia_access_key_id => "aws_access_key_id",
15
- :ia_secret_access_key => "aws_secret_access_key",
16
- :bluebox_api_key => "bluebox_api_key",
17
- :bluebox_customer_id => "bluebox_customer_id",
18
- :brightbox_client_id => "brightbox_client_id",
19
- :brightbox_secret => "brightbox_secret",
20
- :cloudstack_disk_offering_id => "",
21
- :cloudstack_host => "http://cloudstack.example.org",
22
- :cloudstack_network_ids => "",
23
- :cloudstack_service_offering_id => "4437ac6c-9fe3-477a-57ec-60a5a45896a4",
24
- :cloudstack_template_id => "8a31cf9c-f248-0588-256e-9dbf58785216",
25
- :cloudstack_zone_id => "c554c592-e09c-9df5-7688-4a32754a4305",
26
- :clodo_api_key => "clodo_api_key",
27
- :clodo_username => "clodo_username",
28
- :digitalocean_api_key => "digitalocean_api_key",
29
- :digitalocean_client_id => "digitalocean_client_id",
30
- :dnsimple_token => "dnsimple_token",
31
- :dnsimple_account => "dnsimple_account",
32
- :dnsmadeeasy_api_key => "dnsmadeeasy_api_key",
33
- :dnsmadeeasy_secret_key => "dnsmadeeasy_secret_key",
34
- :glesys_username => "glesys_username",
35
- :glesys_api_key => "glesys_api_key",
36
- :go_grid_api_key => "go_grid_api_key",
37
- :go_grid_shared_secret => "go_grid_shared_secret",
38
- :google_storage_access_key_id => "google_storage_access_key_id",
39
- :google_storage_secret_access_key => "google_storage_secret_access_key",
40
- :google_project => "google_project_name",
41
- :google_client_email => "fake@developer.gserviceaccount.com",
42
- :google_key_location => "~/fake.p12",
43
- :hp_access_key => "hp_access_key",
44
- :hp_secret_key => "hp_secret_key",
45
- :hp_tenant_id => "hp_tenant_id",
46
- :hp_avl_zone => "hp_avl_zone",
47
- :os_account_meta_temp_url_key => "os_account_meta_temp_url_key",
48
- :ibm_username => "ibm_username",
49
- :ibm_password => "ibm_password",
50
- :joyent_username => "joyentuser",
51
- :joyent_password => "joyentpass",
52
- :linode_api_key => "linode_api_key",
53
- :local_root => "~/.fog",
54
- :bare_metal_cloud_password => "bare_metal_cloud_password",
55
- :bare_metal_cloud_username => "bare_metal_cloud_username",
56
- :ninefold_compute_key => "ninefold_compute_key",
57
- :ninefold_compute_secret => "ninefold_compute_secret",
58
- :ninefold_storage_secret => "ninefold_storage_secret",
59
- :ninefold_storage_token => "ninefold_storage_token",
12
+ aws_access_key_id: "aws_access_key_id",
13
+ aws_secret_access_key: "aws_secret_access_key",
14
+ ia_access_key_id: "aws_access_key_id",
15
+ ia_secret_access_key: "aws_secret_access_key",
16
+ bluebox_api_key: "bluebox_api_key",
17
+ bluebox_customer_id: "bluebox_customer_id",
18
+ brightbox_client_id: "brightbox_client_id",
19
+ brightbox_secret: "brightbox_secret",
20
+ cloudstack_disk_offering_id: "",
21
+ cloudstack_host: "http://cloudstack.example.org",
22
+ cloudstack_network_ids: "",
23
+ cloudstack_service_offering_id: "4437ac6c-9fe3-477a-57ec-60a5a45896a4",
24
+ cloudstack_template_id: "8a31cf9c-f248-0588-256e-9dbf58785216",
25
+ cloudstack_zone_id: "c554c592-e09c-9df5-7688-4a32754a4305",
26
+ clodo_api_key: "clodo_api_key",
27
+ clodo_username: "clodo_username",
28
+ digitalocean_api_key: "digitalocean_api_key",
29
+ digitalocean_client_id: "digitalocean_client_id",
30
+ dnsimple_token: "dnsimple_token",
31
+ dnsimple_account: "dnsimple_account",
32
+ dnsmadeeasy_api_key: "dnsmadeeasy_api_key",
33
+ dnsmadeeasy_secret_key: "dnsmadeeasy_secret_key",
34
+ glesys_username: "glesys_username",
35
+ glesys_api_key: "glesys_api_key",
36
+ go_grid_api_key: "go_grid_api_key",
37
+ go_grid_shared_secret: "go_grid_shared_secret",
38
+ google_storage_access_key_id: "google_storage_access_key_id",
39
+ google_storage_secret_access_key: "google_storage_secret_access_key",
40
+ google_project: "google_project_name",
41
+ google_client_email: "fake@developer.gserviceaccount.com",
42
+ google_key_location: "~/fake.p12",
43
+ hp_access_key: "hp_access_key",
44
+ hp_secret_key: "hp_secret_key",
45
+ hp_tenant_id: "hp_tenant_id",
46
+ hp_avl_zone: "hp_avl_zone",
47
+ os_account_meta_temp_url_key: "os_account_meta_temp_url_key",
48
+ ibm_username: "ibm_username",
49
+ ibm_password: "ibm_password",
50
+ joyent_username: "joyentuser",
51
+ joyent_password: "joyentpass",
52
+ linode_api_key: "linode_api_key",
53
+ local_root: "~/.fog",
54
+ bare_metal_cloud_password: "bare_metal_cloud_password",
55
+ bare_metal_cloud_username: "bare_metal_cloud_username",
56
+ ninefold_compute_key: "ninefold_compute_key",
57
+ ninefold_compute_secret: "ninefold_compute_secret",
58
+ ninefold_storage_secret: "ninefold_storage_secret",
59
+ ninefold_storage_token: "ninefold_storage_token",
60
60
  # :public_key_path => "~/.ssh/id_rsa.pub",
61
61
  # :private_key_path => "~/.ssh/id_rsa",
62
- :openstack_api_key => "openstack_api_key",
63
- :openstack_username => "openstack_username",
64
- :openstack_tenant => "openstack_tenant",
65
- :openstack_auth_url => "http://openstack:35357/v2.0/tokens",
66
- :ovirt_url => "http://ovirt:8080/api",
67
- :ovirt_username => "admin@internal",
68
- :ovirt_password => "123123",
69
- :rackspace_api_key => "rackspace_api_key",
70
- :rackspace_username => "rackspace_username",
71
- :riakcs_access_key_id => "riakcs_access_key_id",
72
- :riakcs_secret_access_key => "riakcs_secret_access_key",
73
- :vcloud_host => "vcloud_host",
74
- :vcloud_password => "vcloud_password",
75
- :vcloud_username => "vcloud_username",
76
- :vcloud_director_host => "vcloud-director-host",
77
- :vcloud_director_password => "vcloud_director_password",
78
- :vcloud_director_username => "vcd_user@vcd_org_name",
79
- :voxel_api_key => "voxel_api_key",
80
- :voxel_api_secret => "voxel_api_secret",
81
- :zerigo_email => "zerigo_email",
82
- :zerigo_token => "zerigo_token",
83
- :dynect_customer => "dynect_customer",
84
- :dynect_username => "dynect_username",
85
- :dynect_password => "dynect_password",
86
- :vsphere_server => "virtualcenter.lan",
87
- :vsphere_username => "apiuser",
88
- :vsphere_password => "apipassword",
89
- :vsphere_expected_pubkey_hash => "abcdef1234567890",
90
- :libvirt_uri => "qemu:///system",
91
- :libvirt_username => "root",
92
- :libvirt_password => "password",
93
- :cloudsigma_username => "csuname",
94
- :cloudsigma_password => "cspass",
95
- :kubevirt_token => "[TOKEN]",
96
- :kubevirt_hostname => "localhost",
97
- :kubevirt_port => "6443"
62
+ openstack_api_key: "openstack_api_key",
63
+ openstack_username: "openstack_username",
64
+ openstack_tenant: "openstack_tenant",
65
+ openstack_auth_url: "http://openstack:35357/v2.0/tokens",
66
+ ovirt_url: "http://ovirt:8080/api",
67
+ ovirt_username: "admin@internal",
68
+ ovirt_password: "123123",
69
+ rackspace_api_key: "rackspace_api_key",
70
+ rackspace_username: "rackspace_username",
71
+ riakcs_access_key_id: "riakcs_access_key_id",
72
+ riakcs_secret_access_key: "riakcs_secret_access_key",
73
+ vcloud_host: "vcloud_host",
74
+ vcloud_password: "vcloud_password",
75
+ vcloud_username: "vcloud_username",
76
+ vcloud_director_host: "vcloud-director-host",
77
+ vcloud_director_password: "vcloud_director_password",
78
+ vcloud_director_username: "vcd_user@vcd_org_name",
79
+ voxel_api_key: "voxel_api_key",
80
+ voxel_api_secret: "voxel_api_secret",
81
+ zerigo_email: "zerigo_email",
82
+ zerigo_token: "zerigo_token",
83
+ dynect_customer: "dynect_customer",
84
+ dynect_username: "dynect_username",
85
+ dynect_password: "dynect_password",
86
+ vsphere_server: "virtualcenter.lan",
87
+ vsphere_username: "apiuser",
88
+ vsphere_password: "apipassword",
89
+ vsphere_expected_pubkey_hash: "abcdef1234567890",
90
+ libvirt_uri: "qemu:///system",
91
+ libvirt_username: "root",
92
+ libvirt_password: "password",
93
+ cloudsigma_username: "csuname",
94
+ cloudsigma_password: "cspass",
95
+ kubevirt_token: "[TOKEN]",
96
+ kubevirt_hostname: "localhost",
97
+ kubevirt_port: "6443"
98
98
  }.merge(Fog.credentials)
99
99
  end
@@ -1,8 +1,8 @@
1
1
  module Shindo
2
2
  class Tests
3
- def succeeds
3
+ def succeeds(&block)
4
4
  test("succeeds") do
5
- !!instance_eval(&Proc.new)
5
+ !!instance_eval(&block)
6
6
  end
7
7
  end
8
8
  end
@@ -3,6 +3,7 @@
3
3
  # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String)
4
4
  module Fog
5
5
  module Boolean; end
6
+
6
7
  module Nullable
7
8
  module Boolean; end
8
9
  module Integer; end
data/lib/fog/vpn.rb CHANGED
@@ -1,17 +1,5 @@
1
1
  module Fog
2
2
  module VPN
3
3
  extend Fog::ServicesMixin
4
-
5
- def self.new(orig_attributes)
6
- attributes = orig_attributes.dup
7
- provider = attributes.delete(:provider).to_s.downcase.to_sym
8
-
9
- if provider == :stormondemand
10
- require "fog/vpn/storm_on_demand"
11
- Fog::VPN::StormOnDemand.new(attributes)
12
- else
13
- super(orig_attributes)
14
- end
15
- end
16
4
  end
17
5
  end
@@ -27,8 +27,8 @@ module Fog
27
27
  Fog.providers.each do |key, value|
28
28
  threads << Thread.new do
29
29
  Thread.main[:results] << {
30
- :provider => value,
31
- :success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
30
+ provider: value,
31
+ success: sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
32
32
  }
33
33
  end
34
34
  end
@@ -26,13 +26,13 @@ describe Fog::Compute::Server do
26
26
  end
27
27
  end
28
28
 
29
-
30
29
  describe "when the ssh_ip_address exists" do
31
30
  # Define these constants which would be imported by net-ssh once loaded
32
31
  module Net
33
32
  module SSH
34
33
  class AuthenticationFailed < RuntimeError
35
34
  end
35
+
36
36
  class Disconnect < RuntimeError
37
37
  end
38
38
  end
@@ -55,7 +55,7 @@ describe Fog::Compute::Server do
55
55
  it "is false" do
56
56
  @server.stub(:ready?, true) do
57
57
  @server.stub(:ssh_ip_address, "10.0.0.1") do
58
- raise_error = lambda { |_cmd, _options| raise Net::SSH::AuthenticationFailed.new }
58
+ raise_error = lambda { |_cmd, _options={}| raise Net::SSH::AuthenticationFailed.new }
59
59
  @server.stub(:ssh, raise_error) do
60
60
  refute @server.sshable?
61
61
  end
@@ -67,7 +67,7 @@ describe Fog::Compute::Server do
67
67
  @server.instance_variable_set(:@sshable_timeout, 8)
68
68
  @server.stub(:ready?, true) do
69
69
  @server.stub(:ssh_ip_address, "10.0.0.1") do
70
- raise_error = lambda { |_cmd, _options| raise Net::SSH::AuthenticationFailed.new }
70
+ raise_error = lambda { |_cmd, _options={}| raise Net::SSH::AuthenticationFailed.new }
71
71
  @server.stub(:ssh, raise_error) do
72
72
  @server.sshable?
73
73
  assert_nil @server.instance_variable_get(:@sshable_timeout), nil
@@ -81,7 +81,7 @@ describe Fog::Compute::Server do
81
81
  it "is false" do
82
82
  @server.stub(:ready?, true) do
83
83
  @server.stub(:ssh_ip_address, "10.0.0.1") do
84
- raise_error = lambda { |_cmd, _options| raise Net::SSH::Disconnect.new }
84
+ raise_error = lambda { |_cmd, _options={}| raise Net::SSH::Disconnect.new }
85
85
  @server.stub(:ssh, raise_error) do
86
86
  refute @server.sshable?
87
87
  end
@@ -93,7 +93,7 @@ describe Fog::Compute::Server do
93
93
  @server.instance_variable_set(:@sshable_timeout, 8)
94
94
  @server.stub(:ready?, true) do
95
95
  @server.stub(:ssh_ip_address, "10.0.0.1") do
96
- raise_error = lambda { |_cmd, _options| raise Net::SSH::Disconnect.new }
96
+ raise_error = lambda { |_cmd, _options={}| raise Net::SSH::Disconnect.new }
97
97
  @server.stub(:ssh, raise_error) do
98
98
  @server.sshable?
99
99
  assert_nil @server.instance_variable_get(:@sshable_timeout), nil
@@ -107,7 +107,7 @@ describe Fog::Compute::Server do
107
107
  it "is false" do
108
108
  @server.stub(:ready?, true) do
109
109
  @server.stub(:ssh_ip_address, "10.0.0.1") do
110
- raise_error = lambda { |_cmd, _options| raise SystemCallError.new("message, 0") }
110
+ raise_error = lambda { |_cmd, _options={}| raise SystemCallError.new("message, 0") }
111
111
  @server.stub(:ssh, raise_error) do
112
112
  refute @server.sshable?
113
113
  end
@@ -118,7 +118,7 @@ describe Fog::Compute::Server do
118
118
  it "does not increase SSH timeout" do
119
119
  @server.stub(:ready?, true) do
120
120
  @server.stub(:ssh_ip_address, "10.0.0.1") do
121
- raise_error = lambda { |_cmd, _options| raise SystemCallError.new("message, 0") }
121
+ raise_error = lambda { |_cmd, _options={}| raise SystemCallError.new("message, 0") }
122
122
  @server.stub(:ssh, raise_error) do
123
123
  @server.sshable?
124
124
  assert_equal @server.instance_variable_get(:@sshable_timeout), 8
data/spec/compute_spec.rb CHANGED
@@ -10,55 +10,51 @@ describe "Fog::Compute" do
10
10
  describe "#new" do
11
11
  module Fog
12
12
  module TheRightWay
13
- extend Provider
14
- service(:compute, "Compute")
15
- end
16
- end
17
-
18
- module Fog
19
- module Compute
20
- class TheRightWay
13
+ class Compute
21
14
  def initialize(_args); end
22
15
  end
23
16
  end
24
17
  end
25
18
 
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::Compute::TheRightWay, compute)
29
- end
30
-
31
19
  module Fog
32
- module TheWrongWay
20
+ module TheRightWay
33
21
  extend Provider
34
22
  service(:compute, "Compute")
35
23
  end
36
24
  end
37
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
+
38
31
  module Fog
39
- module TheWrongWay
40
- class Compute
32
+ module Compute
33
+ class TheWrongWay
41
34
  def initialize(_args); end
42
35
  end
43
36
  end
44
37
  end
45
38
 
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::TheWrongWay::Compute, compute)
49
- end
50
-
51
39
  module Fog
52
- module BothWays
40
+ module TheWrongWay
53
41
  extend Provider
54
42
  service(:compute, "Compute")
55
43
  end
56
44
  end
57
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
+
58
51
  module Fog
59
52
  module BothWays
60
53
  class Compute
61
- def initialize(_args); end
54
+ attr_reader :args
55
+ def initialize(args)
56
+ @args = args
57
+ end
62
58
  end
63
59
  end
64
60
  end
@@ -66,29 +62,33 @@ describe "Fog::Compute" do
66
62
  module Fog
67
63
  module Compute
68
64
  class BothWays
69
- attr_reader :args
70
- def initialize(args)
71
- @args = args
72
- end
65
+ def initialize(_args); end
73
66
  end
74
67
  end
75
68
  end
76
69
 
70
+ module Fog
71
+ module BothWays
72
+ extend Provider
73
+ service(:compute, "Compute")
74
+ end
75
+ end
76
+
77
77
  describe "when both Fog::Compute::<Provider> and Fog::<Provider>::Compute exist" do
78
- it "prefers Fog::Compute::<Provider>" do
79
- compute = Fog::Compute.new(:provider => :bothways)
80
- assert_instance_of(Fog::Compute::BothWays, compute)
78
+ it "prefers Fog::<Provider>::Compute" do
79
+ compute = Fog::Compute.new(provider: :bothways)
80
+ assert_instance_of(Fog::BothWays::Compute, compute)
81
81
  end
82
82
  end
83
83
 
84
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)
85
+ compute = Fog::Compute.new(provider: :bothways, extra: :stuff)
86
+ assert_equal({ extra: :stuff }, compute.args)
87
87
  end
88
88
 
89
89
  it "raises ArgumentError when given a :provider where a Fog::Compute::Provider that does not exist" do
90
90
  assert_raises(ArgumentError) do
91
- Fog::Compute.new(:provider => :wat)
91
+ Fog::Compute.new(provider: :wat)
92
92
  end
93
93
  end
94
94
  end