fog-core 2.2.4 → 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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +2 -0
  3. data/.github/workflows/ruby.yml +1 -17
  4. data/.github/workflows/stale.yml +1 -15
  5. data/.rubocop.yml +16 -12
  6. data/.rubocop_todo.yml +724 -0
  7. data/Gemfile +1 -1
  8. data/Rakefile +2 -14
  9. data/changelog.md +33 -3
  10. data/fog-core.gemspec +11 -8
  11. data/lib/fog/compute/models/server.rb +7 -3
  12. data/lib/fog/compute.rb +2 -2
  13. data/lib/fog/core/association.rb +1 -0
  14. data/lib/fog/core/attributes/default.rb +7 -0
  15. data/lib/fog/core/attributes.rb +28 -3
  16. data/lib/fog/core/cache.rb +58 -55
  17. data/lib/fog/core/collection.rb +9 -3
  18. data/lib/fog/core/connection.rb +1 -1
  19. data/lib/fog/core/current_machine.rb +1 -1
  20. data/lib/fog/core/errors.rb +1 -1
  21. data/lib/fog/core/logger.rb +2 -2
  22. data/lib/fog/core/mock.rb +6 -1
  23. data/lib/fog/core/model.rb +34 -5
  24. data/lib/fog/core/provider.rb +18 -17
  25. data/lib/fog/core/scp.rb +15 -11
  26. data/lib/fog/core/service.rb +4 -4
  27. data/lib/fog/core/services_mixin.rb +9 -9
  28. data/lib/fog/core/ssh.rb +3 -2
  29. data/lib/fog/core/stringify_keys.rb +0 -2
  30. data/lib/fog/core/time.rb +2 -2
  31. data/lib/fog/core/uuid.rb +2 -8
  32. data/lib/fog/core/version.rb +1 -1
  33. data/lib/fog/core/wait_for.rb +2 -1
  34. data/lib/fog/core/wait_for_defaults.rb +2 -0
  35. data/lib/fog/core.rb +57 -58
  36. data/lib/fog/formatador.rb +7 -6
  37. data/lib/fog/schema/data_validator.rb +1 -0
  38. data/lib/fog/storage.rb +15 -15
  39. data/lib/fog/test_helpers/collection_helper.rb +2 -0
  40. data/lib/fog/test_helpers/formats_helper.rb +2 -2
  41. data/lib/fog/test_helpers/helper.rb +3 -3
  42. data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
  43. data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
  44. data/lib/fog/test_helpers/mock_helper.rb +84 -84
  45. data/lib/fog/test_helpers/types_helper.rb +1 -0
  46. data/lib/tasks/test_task.rb +2 -2
  47. data/spec/compute/models/server_spec.rb +7 -7
  48. data/spec/compute_spec.rb +23 -23
  49. data/spec/connection_spec.rb +11 -9
  50. data/spec/core/cache_spec.rb +52 -16
  51. data/spec/core/collection_spec.rb +24 -0
  52. data/spec/core/model_spec.rb +36 -3
  53. data/spec/core/stringify_keys_spec.rb +3 -3
  54. data/spec/core/whitelist_keys_spec.rb +2 -2
  55. data/spec/current_machine_spec.rb +2 -2
  56. data/spec/fog_attribute_spec.rb +183 -163
  57. data/spec/formatador_spec.rb +7 -7
  58. data/spec/identity_spec.rb +23 -23
  59. data/spec/mocking_spec.rb +3 -3
  60. data/spec/service_spec.rb +19 -19
  61. data/spec/spec_helper.rb +3 -8
  62. data/spec/storage_spec.rb +23 -23
  63. data/spec/test_helpers/formats_helper_spec.rb +8 -8
  64. data/spec/test_helpers/schema_validator_spec.rb +8 -8
  65. data/spec/utils_spec.rb +6 -6
  66. data/spec/wait_for_spec.rb +2 -2
  67. metadata +51 -54
@@ -3,6 +3,17 @@ require "securerandom"
3
3
 
4
4
  class FogTestModel < Fog::Model
5
5
  identity :id
6
+ attribute :value
7
+
8
+ def create
9
+ self.identity = SecureRandom.hex
10
+ self
11
+ end
12
+
13
+ def update
14
+ self.value = 42
15
+ self
16
+ end
6
17
  end
7
18
 
8
19
  describe Fog::Model do
@@ -21,7 +32,7 @@ describe Fog::Model do
21
32
 
22
33
  it "is equal if it has the same non-nil identity and the same class" do
23
34
  id = SecureRandom.hex
24
- assert_equal FogTestModel.new(:id => id), FogTestModel.new(:id => id)
35
+ assert_equal FogTestModel.new(id: id), FogTestModel.new(id: id)
25
36
  end
26
37
 
27
38
  it "is not equal if both have nil identity, but are different objects" do
@@ -29,8 +40,30 @@ describe Fog::Model do
29
40
  end
30
41
 
31
42
  it "is not equal if it has a different identity" do
32
- refute_equal FogTestModel.new(:id => SecureRandom.hex),
33
- FogTestModel.new(:id => SecureRandom.hex)
43
+ refute_equal FogTestModel.new(id: SecureRandom.hex),
44
+ FogTestModel.new(id: SecureRandom.hex)
45
+ end
46
+ end
47
+
48
+ describe "#save" do
49
+ describe "on a non persisted object" do
50
+ it "creates a new resource" do
51
+ a = FogTestModel.new
52
+ a.stub(:persisted?, false) do
53
+ a.save
54
+ refute_nil(a.identity)
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "on a persisted object" do
60
+ it "updates resource" do
61
+ a = FogTestModel.new
62
+ a.stub(:persisted?, true) do
63
+ a.save
64
+ assert_equal(a.value, 42)
65
+ end
66
+ end
34
67
  end
35
68
  end
36
69
  end
@@ -4,7 +4,7 @@ describe "Fog::StringifyKeys" do
4
4
  describe ".stringify" do
5
5
  describe "when key is a Symbol" do
6
6
  it "replaces key with String" do
7
- input = { :key => "value" }
7
+ input = { key: "value" }
8
8
  output = Fog::StringifyKeys.stringify(input)
9
9
  assert(output.key?("key"))
10
10
  end
@@ -26,11 +26,11 @@ describe "Fog::StringifyKeys" do
26
26
 
27
27
  describe "when keys are deeply nested" do
28
28
  it "updates only top level key" do
29
- input = { :key1 => { :key2 => { :key3 => nil }}}
29
+ input = { key1: { key2: { key3: nil }}}
30
30
 
31
31
  output = Fog::StringifyKeys.stringify(input)
32
32
 
33
- expected = { "key1" => { :key2 => { :key3 => nil }}}
33
+ expected = { "key1" => { key2: { key3: nil }}}
34
34
  assert_equal(expected, output)
35
35
  end
36
36
  end
@@ -4,7 +4,7 @@ describe "Fog::WhitelistKeys" do
4
4
  describe ".whitelist" do
5
5
  describe "when other keys are present" do
6
6
  it "returns Hash with only allowed keys" do
7
- input = { :name => "name", :type => "type", :size => 80 }
7
+ input = { name: "name", type: "type", size: 80 }
8
8
  valid_keys = %w(name size)
9
9
 
10
10
  output = Fog::WhitelistKeys.whitelist(input, valid_keys)
@@ -16,7 +16,7 @@ describe "Fog::WhitelistKeys" do
16
16
 
17
17
  describe "when key is a Symbol" do
18
18
  it "returns a String" do
19
- input = { :name => "name" }
19
+ input = { name: "name" }
20
20
  valid_keys = %w(name)
21
21
 
22
22
  output = Fog::WhitelistKeys.whitelist(input, valid_keys)
@@ -22,14 +22,14 @@ describe Fog::CurrentMachine do
22
22
 
23
23
  (1..10).map do
24
24
  Thread.new do
25
- Excon.stub({ :method => :get, :path => "/" }, { :body => "" })
25
+ Excon.stub({ method: :get, path: "/" }, { body: "" })
26
26
  Fog::CurrentMachine.ip_address
27
27
  end
28
28
  end.each(&:join)
29
29
  end
30
30
 
31
31
  it "should remove trailing endline characters" do
32
- Excon.stub({ :method => :get, :path => "/" }, { :body => "192.168.0.1\n" })
32
+ Excon.stub({ method: :get, path: "/" }, { body: "192.168.0.1\n" })
33
33
  assert_equal "192.168.0.1", Fog::CurrentMachine.ip_address
34
34
  end
35
35
  end