fog-core 1.24.0 → 1.25.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.
- checksums.yaml +5 -13
 - data/.rubocop.yml +20 -0
 - data/changelog.md +17 -0
 - data/fog-core.gemspec +2 -1
 - data/lib/fog/account.rb +3 -5
 - data/lib/fog/billing.rb +3 -4
 - data/lib/fog/cdn.rb +3 -5
 - data/lib/fog/compute.rb +17 -20
 - data/lib/fog/compute/models/server.rb +21 -26
 - data/lib/fog/core.rb +61 -60
 - data/lib/fog/core/association.rb +15 -0
 - data/lib/fog/core/associations/default.rb +21 -3
 - data/lib/fog/core/associations/many_identities.rb +8 -2
 - data/lib/fog/core/associations/many_models.rb +7 -2
 - data/lib/fog/core/associations/one_identity.rb +6 -1
 - data/lib/fog/core/associations/one_model.rb +5 -1
 - data/lib/fog/core/attributes.rb +41 -44
 - data/lib/fog/core/attributes/array.rb +5 -1
 - data/lib/fog/core/attributes/boolean.rb +5 -1
 - data/lib/fog/core/attributes/default.rb +12 -2
 - data/lib/fog/core/attributes/float.rb +5 -1
 - data/lib/fog/core/attributes/integer.rb +5 -1
 - data/lib/fog/core/attributes/string.rb +5 -1
 - data/lib/fog/core/attributes/time.rb +5 -1
 - data/lib/fog/core/attributes/timestamp.rb +5 -1
 - data/lib/fog/core/collection.rb +22 -27
 - data/lib/fog/core/connection.rb +5 -6
 - data/lib/fog/core/credentials.rb +7 -7
 - data/lib/fog/core/current_machine.rb +10 -8
 - data/lib/fog/core/deprecated_connection_accessors.rb +0 -1
 - data/lib/fog/core/deprecation.rb +0 -2
 - data/lib/fog/core/errors.rb +3 -5
 - data/lib/fog/core/hmac.rb +4 -6
 - data/lib/fog/core/logger.rb +10 -11
 - data/lib/fog/core/mock.rb +19 -25
 - data/lib/fog/core/model.rb +9 -20
 - data/lib/fog/core/provider.rb +6 -9
 - data/lib/fog/core/scp.rb +14 -24
 - data/lib/fog/core/service.rb +28 -31
 - data/lib/fog/core/ssh.rb +16 -24
 - data/lib/fog/core/stringify_keys.rb +7 -9
 - data/lib/fog/core/time.rb +5 -7
 - data/lib/fog/core/utils.rb +24 -20
 - data/lib/fog/core/uuid.rb +2 -3
 - data/lib/fog/core/version.rb +3 -1
 - data/lib/fog/core/wait_for.rb +2 -2
 - data/lib/fog/core/wait_for_defaults.rb +13 -10
 - data/lib/fog/core/whitelist_keys.rb +1 -1
 - data/lib/fog/dns.rb +6 -8
 - data/lib/fog/identity.rb +5 -6
 - data/lib/fog/image.rb +3 -5
 - data/lib/fog/metering.rb +3 -6
 - data/lib/fog/monitoring.rb +3 -5
 - data/lib/fog/network.rb +4 -6
 - data/lib/fog/orchestration.rb +3 -5
 - data/lib/fog/schema/data_validator.rb +17 -22
 - data/lib/fog/storage.rb +22 -16
 - data/lib/fog/support.rb +3 -6
 - data/lib/fog/test_helpers.rb +10 -10
 - data/lib/fog/test_helpers/collection_helper.rb +23 -43
 - data/lib/fog/test_helpers/compute/flavors_helper.rb +4 -10
 - data/lib/fog/test_helpers/compute/server_helper.rb +3 -9
 - data/lib/fog/test_helpers/compute/servers_helper.rb +0 -4
 - data/lib/fog/test_helpers/formats_helper.rb +13 -14
 - data/lib/fog/test_helpers/helper.rb +9 -4
 - data/lib/fog/test_helpers/mock_helper.rb +92 -94
 - data/lib/fog/test_helpers/model_helper.rb +7 -15
 - data/lib/fog/test_helpers/responds_to_helper.rb +1 -3
 - data/lib/fog/test_helpers/succeeds_helper.rb +1 -3
 - data/lib/fog/volume.rb +3 -6
 - data/lib/fog/vpn.rb +3 -5
 - data/lib/tasks/test_task.rb +2 -6
 - data/spec/compute_spec.rb +11 -13
 - data/spec/connection_spec.rb +24 -14
 - data/spec/credentials_spec.rb +23 -23
 - data/spec/current_machine_spec.rb +6 -6
 - data/spec/fake_app/fake_service.rb +18 -0
 - data/spec/fake_app/models/collection.rb +5 -0
 - data/spec/fake_app/models/model.rb +2 -0
 - data/spec/fake_app/requests/request.rb +11 -0
 - data/spec/fog_attribute_spec.rb +178 -136
 - data/spec/identity_spec.rb +11 -13
 - data/spec/mocking_spec.rb +7 -8
 - data/spec/service_spec.rb +21 -7
 - data/spec/spec_helper.rb +14 -8
 - data/spec/storage_spec.rb +25 -13
 - data/spec/test_helpers/formats_helper_spec.rb +52 -52
 - data/spec/test_helpers/schema_validator_spec.rb +45 -45
 - data/spec/timeout_spec.rb +1 -2
 - data/spec/utils_spec.rb +2 -2
 - data/spec/uuid_spec.rb +1 -1
 - data/spec/wait_for_spec.rb +7 -4
 - metadata +57 -33
 
    
        data/spec/identity_spec.rb
    CHANGED
    
    | 
         @@ -1,9 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            module Fog
         
     | 
| 
       5 
4 
     | 
    
         
             
              module Identity
         
     | 
| 
       6 
     | 
    
         
            -
                def self.require(* 
     | 
| 
      
 5 
     | 
    
         
            +
                def self.require(*_args); end
         
     | 
| 
       7 
6 
     | 
    
         
             
              end
         
     | 
| 
       8 
7 
     | 
    
         
             
            end
         
     | 
| 
       9 
8 
     | 
    
         | 
| 
         @@ -12,14 +11,14 @@ describe "Fog::Identity" do 
     | 
|
| 
       12 
11 
     | 
    
         
             
                module Fog
         
     | 
| 
       13 
12 
     | 
    
         
             
                  module TheRightWay
         
     | 
| 
       14 
13 
     | 
    
         
             
                    extend Provider
         
     | 
| 
       15 
     | 
    
         
            -
                    service(:identity,  
     | 
| 
      
 14 
     | 
    
         
            +
                    service(:identity, "Identity")
         
     | 
| 
       16 
15 
     | 
    
         
             
                  end
         
     | 
| 
       17 
16 
     | 
    
         
             
                end
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
18 
     | 
    
         
             
                module Fog
         
     | 
| 
       20 
19 
     | 
    
         
             
                  module Identity
         
     | 
| 
       21 
20 
     | 
    
         
             
                    class TheRightWay
         
     | 
| 
       22 
     | 
    
         
            -
                      def initialize( 
     | 
| 
      
 21 
     | 
    
         
            +
                      def initialize(_args); end
         
     | 
| 
       23 
22 
     | 
    
         
             
                    end
         
     | 
| 
       24 
23 
     | 
    
         
             
                  end
         
     | 
| 
       25 
24 
     | 
    
         
             
                end
         
     | 
| 
         @@ -29,18 +28,17 @@ describe "Fog::Identity" do 
     | 
|
| 
       29 
28 
     | 
    
         
             
                  assert_instance_of(Fog::Identity::TheRightWay, identity)
         
     | 
| 
       30 
29 
     | 
    
         
             
                end
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
31 
     | 
    
         
             
                module Fog
         
     | 
| 
       34 
32 
     | 
    
         
             
                  module Rackspace
         
     | 
| 
       35 
33 
     | 
    
         
             
                    extend Provider
         
     | 
| 
       36 
     | 
    
         
            -
                    service(:identity,  
     | 
| 
      
 34 
     | 
    
         
            +
                    service(:identity, "Identity")
         
     | 
| 
       37 
35 
     | 
    
         
             
                  end
         
     | 
| 
       38 
36 
     | 
    
         
             
                end
         
     | 
| 
       39 
37 
     | 
    
         | 
| 
       40 
38 
     | 
    
         
             
                module Fog
         
     | 
| 
       41 
39 
     | 
    
         
             
                  module Rackspace
         
     | 
| 
       42 
40 
     | 
    
         
             
                    class Identity
         
     | 
| 
       43 
     | 
    
         
            -
                      def initialize( 
     | 
| 
      
 41 
     | 
    
         
            +
                      def initialize(_args); end
         
     | 
| 
       44 
42 
     | 
    
         
             
                    end
         
     | 
| 
       45 
43 
     | 
    
         
             
                  end
         
     | 
| 
       46 
44 
     | 
    
         
             
                end
         
     | 
| 
         @@ -53,14 +51,14 @@ describe "Fog::Identity" do 
     | 
|
| 
       53 
51 
     | 
    
         
             
                module Fog
         
     | 
| 
       54 
52 
     | 
    
         
             
                  module BothWays
         
     | 
| 
       55 
53 
     | 
    
         
             
                    extend Provider
         
     | 
| 
       56 
     | 
    
         
            -
                    service(:identity,  
     | 
| 
      
 54 
     | 
    
         
            +
                    service(:identity, "Identity")
         
     | 
| 
       57 
55 
     | 
    
         
             
                  end
         
     | 
| 
       58 
56 
     | 
    
         
             
                end
         
     | 
| 
       59 
57 
     | 
    
         | 
| 
       60 
58 
     | 
    
         
             
                module Fog
         
     | 
| 
       61 
59 
     | 
    
         
             
                  module BothWays
         
     | 
| 
       62 
60 
     | 
    
         
             
                    class Identity
         
     | 
| 
       63 
     | 
    
         
            -
                      def initialize( 
     | 
| 
      
 61 
     | 
    
         
            +
                      def initialize(_args); end
         
     | 
| 
       64 
62 
     | 
    
         
             
                    end
         
     | 
| 
       65 
63 
     | 
    
         
             
                  end
         
     | 
| 
       66 
64 
     | 
    
         
             
                end
         
     | 
| 
         @@ -82,16 +80,16 @@ describe "Fog::Identity" do 
     | 
|
| 
       82 
80 
     | 
    
         
             
                    assert_instance_of(Fog::Identity::BothWays, identity)
         
     | 
| 
       83 
81 
     | 
    
         
             
                  end
         
     | 
| 
       84 
82 
     | 
    
         
             
                end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
       86 
84 
     | 
    
         
             
                it "passes the supplied keyword args less :provider to Fog::Identity::<Provider>#new" do
         
     | 
| 
       87 
85 
     | 
    
         
             
                  identity = Fog::Identity.new(:provider => :bothways, :extra => :stuff)
         
     | 
| 
       88 
     | 
    
         
            -
                  assert_equal({:extra => :stuff}, identity.args)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  assert_equal({ :extra => :stuff }, identity.args)
         
     | 
| 
       89 
87 
     | 
    
         
             
                end
         
     | 
| 
       90 
88 
     | 
    
         | 
| 
       91 
89 
     | 
    
         
             
                it "raises ArgumentError when given a :provider where a Fog::Identity::Provider that does not exist" do
         
     | 
| 
       92 
90 
     | 
    
         
             
                  assert_raises(ArgumentError) do
         
     | 
| 
       93 
91 
     | 
    
         
             
                    Fog::Identity.new(:provider => :wat)
         
     | 
| 
       94 
92 
     | 
    
         
             
                  end
         
     | 
| 
       95 
     | 
    
         
            -
                end 
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
       96 
94 
     | 
    
         
             
              end
         
     | 
| 
       97 
95 
     | 
    
         
             
            end
         
     | 
    
        data/spec/mocking_spec.rb
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe "Fog mocking" do
         
     | 
| 
       4 
4 
     | 
    
         
             
              before do
         
     | 
| 
         @@ -14,7 +14,7 @@ describe "Fog mocking" do 
     | 
|
| 
       14 
14 
     | 
    
         
             
                it "Fog.mock! returns true" do
         
     | 
| 
       15 
15 
     | 
    
         
             
                  assert_equal true, Fog.mock!
         
     | 
| 
       16 
16 
     | 
    
         
             
                end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
       18 
18 
     | 
    
         
             
                it "Fog.mock? without Fog.mock! returns false" do
         
     | 
| 
       19 
19 
     | 
    
         
             
                  assert_equal false, Fog.mock?
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
         @@ -58,18 +58,18 @@ describe "Fog mocking" do 
     | 
|
| 
       58 
58 
     | 
    
         
             
                it "defaults to ipv4" do
         
     | 
| 
       59 
59 
     | 
    
         
             
                  assert IPAddr.new(Fog::Mock.random_ip).ipv4?
         
     | 
| 
       60 
60 
     | 
    
         
             
                end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       62 
62 
     | 
    
         
             
                it "supports explicit request for v4" do
         
     | 
| 
       63 
     | 
    
         
            -
                  assert IPAddr.new(Fog::Mock.random_ip( 
     | 
| 
      
 63 
     | 
    
         
            +
                  assert IPAddr.new(Fog::Mock.random_ip(:version => :v4)).ipv4?
         
     | 
| 
       64 
64 
     | 
    
         
             
                end
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
       66 
66 
     | 
    
         
             
                it "supports explicit request for v6" do
         
     | 
| 
       67 
     | 
    
         
            -
                  assert IPAddr.new(Fog::Mock.random_ip( 
     | 
| 
      
 67 
     | 
    
         
            +
                  assert IPAddr.new(Fog::Mock.random_ip(:version => :v6)).ipv6?
         
     | 
| 
       68 
68 
     | 
    
         
             
                end
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
                it "raises when supplied an illegal IP version"do 
     | 
| 
      
 70 
     | 
    
         
            +
                it "raises when supplied an illegal IP version" do
         
     | 
| 
       71 
71 
     | 
    
         
             
                  assert_raises(ArgumentError) do
         
     | 
| 
       72 
     | 
    
         
            -
                    IPAddr.new(Fog::Mock.random_ip( 
     | 
| 
      
 72 
     | 
    
         
            +
                    IPAddr.new(Fog::Mock.random_ip(:version => :v5)).ipv4?
         
     | 
| 
       73 
73 
     | 
    
         
             
                  end
         
     | 
| 
       74 
74 
     | 
    
         
             
                end
         
     | 
| 
       75 
75 
     | 
    
         
             
              end
         
     | 
| 
         @@ -82,4 +82,3 @@ describe "Fog mocking" do 
     | 
|
| 
       82 
82 
     | 
    
         
             
                end
         
     | 
| 
       83 
83 
     | 
    
         
             
              end
         
     | 
| 
       84 
84 
     | 
    
         
             
            end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
    
        data/spec/service_spec.rb
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Fog::Service do
         
     | 
| 
       4 
4 
     | 
    
         
             
              class TestService < Fog::Service
         
     | 
| 
         @@ -23,8 +23,8 @@ describe Fog::Service do 
     | 
|
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              class ChildOfTestService < TestService
         
     | 
| 
       26 
     | 
    
         
            -
                class Real; def initialize(* 
     | 
| 
       27 
     | 
    
         
            -
                class Mock; def initialize(* 
     | 
| 
      
 26 
     | 
    
         
            +
                class Real; def initialize(*_args); end; end
         
     | 
| 
      
 27 
     | 
    
         
            +
                class Mock; def initialize(*_args); end; end
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
              it "properly passes headers" do
         
     | 
| 
         @@ -98,7 +98,7 @@ describe Fog::Service do 
     | 
|
| 
       98 
98 
     | 
    
         
             
                    assert_includes(service.class.ancestors, TestService::Collections)
         
     | 
| 
       99 
99 
     | 
    
         
             
                    assert_includes(service.class.ancestors, Fog::Service::Collections)
         
     | 
| 
       100 
100 
     | 
    
         
             
                    refute_includes(service.class.ancestors, ChildOfTestService::Collections)
         
     | 
| 
       101 
     | 
    
         
            -
                  end 
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
       102 
102 
     | 
    
         
             
                end
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
104 
     | 
    
         
             
                it "ChildOfTestService::Real has ChildOfTestService::Collections and TestService::Collections mixed in" do
         
     | 
| 
         @@ -107,7 +107,7 @@ describe Fog::Service do 
     | 
|
| 
       107 
107 
     | 
    
         
             
                    assert_includes(service.class.ancestors, Fog::Service::Collections)
         
     | 
| 
       108 
108 
     | 
    
         
             
                    assert_includes(service.class.ancestors, TestService::Collections)
         
     | 
| 
       109 
109 
     | 
    
         
             
                    assert_includes(service.class.ancestors, ChildOfTestService::Collections)
         
     | 
| 
       110 
     | 
    
         
            -
                  end 
     | 
| 
      
 110 
     | 
    
         
            +
                  end
         
     | 
| 
       111 
111 
     | 
    
         
             
                end
         
     | 
| 
       112 
112 
     | 
    
         
             
              end
         
     | 
| 
       113 
113 
     | 
    
         | 
| 
         @@ -125,7 +125,7 @@ describe Fog::Service do 
     | 
|
| 
       125 
125 
     | 
    
         
             
                    assert_includes(service.class.ancestors, Fog::Service::Collections)
         
     | 
| 
       126 
126 
     | 
    
         
             
                    assert_includes(service.class.ancestors, TestService::Collections)
         
     | 
| 
       127 
127 
     | 
    
         
             
                    refute_includes(service.class.ancestors, ChildOfTestService::Collections)
         
     | 
| 
       128 
     | 
    
         
            -
                  end 
     | 
| 
      
 128 
     | 
    
         
            +
                  end
         
     | 
| 
       129 
129 
     | 
    
         
             
                end
         
     | 
| 
       130 
130 
     | 
    
         | 
| 
       131 
131 
     | 
    
         
             
                it "ChildOfTestService::Mock has ChildOfTestService::Collections and TestService::Collections mixed in" do
         
     | 
| 
         @@ -134,7 +134,7 @@ describe Fog::Service do 
     | 
|
| 
       134 
134 
     | 
    
         
             
                    assert_includes(service.class.ancestors, Fog::Service::Collections)
         
     | 
| 
       135 
135 
     | 
    
         
             
                    assert_includes(service.class.ancestors, TestService::Collections)
         
     | 
| 
       136 
136 
     | 
    
         
             
                    assert_includes(service.class.ancestors, ChildOfTestService::Collections)
         
     | 
| 
       137 
     | 
    
         
            -
                  end 
     | 
| 
      
 137 
     | 
    
         
            +
                  end
         
     | 
| 
       138 
138 
     | 
    
         
             
                end
         
     | 
| 
       139 
139 
     | 
    
         
             
              end
         
     | 
| 
       140 
140 
     | 
    
         | 
| 
         @@ -183,4 +183,18 @@ describe Fog::Service do 
     | 
|
| 
       183 
183 
     | 
    
         
             
                  end
         
     | 
| 
       184 
184 
     | 
    
         
             
                end
         
     | 
| 
       185 
185 
     | 
    
         
             
              end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
              describe "#setup_requirements" do
         
     | 
| 
      
 188 
     | 
    
         
            +
                before :each do
         
     | 
| 
      
 189 
     | 
    
         
            +
                  @service = FakeService.new
         
     | 
| 
      
 190 
     | 
    
         
            +
                end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
                it "should require collections" do
         
     | 
| 
      
 193 
     | 
    
         
            +
                  assert @service.respond_to?(:collection)
         
     | 
| 
      
 194 
     | 
    
         
            +
                end
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                it "should mock" do
         
     | 
| 
      
 197 
     | 
    
         
            +
                  assert_includes @service.mocked_requests, :request
         
     | 
| 
      
 198 
     | 
    
         
            +
                end
         
     | 
| 
      
 199 
     | 
    
         
            +
              end
         
     | 
| 
       186 
200 
     | 
    
         
             
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,16 +1,22 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "rubygems"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "minitest/autorun"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "minitest/spec"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "minitest/stub_const"
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            $LOAD_PATH.unshift "lib"
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            if ENV[ 
     | 
| 
       8 
     | 
    
         
            -
              require  
     | 
| 
       9 
     | 
    
         
            -
              require  
     | 
| 
      
 9 
     | 
    
         
            +
            if ENV["COVERAGE"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              require "coveralls"
         
     | 
| 
      
 11 
     | 
    
         
            +
              require "simplecov"
         
     | 
| 
       10 
12 
     | 
    
         | 
| 
       11 
13 
     | 
    
         
             
              SimpleCov.start do
         
     | 
| 
       12 
     | 
    
         
            -
                add_filter  
     | 
| 
      
 14 
     | 
    
         
            +
                add_filter "/spec/"
         
     | 
| 
       13 
15 
     | 
    
         
             
              end
         
     | 
| 
       14 
16 
     | 
    
         
             
            end
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
            require  
     | 
| 
      
 18 
     | 
    
         
            +
            require "fog/core"
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            Dir["spec/fake_app/**/*.rb"].each do |file|
         
     | 
| 
      
 21 
     | 
    
         
            +
              require File.join(File.dirname(__FILE__), "..", file)
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/storage_spec.rb
    CHANGED
    
    | 
         @@ -1,9 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            module Fog
         
     | 
| 
       5 
4 
     | 
    
         
             
              module Storage
         
     | 
| 
       6 
     | 
    
         
            -
                def self.require(* 
     | 
| 
      
 5 
     | 
    
         
            +
                def self.require(*_args); end
         
     | 
| 
       7 
6 
     | 
    
         
             
              end
         
     | 
| 
       8 
7 
     | 
    
         
             
            end
         
     | 
| 
       9 
8 
     | 
    
         | 
| 
         @@ -12,14 +11,14 @@ describe "Fog::Storage" do 
     | 
|
| 
       12 
11 
     | 
    
         
             
                module Fog
         
     | 
| 
       13 
12 
     | 
    
         
             
                  module TheRightWay
         
     | 
| 
       14 
13 
     | 
    
         
             
                    extend Provider
         
     | 
| 
       15 
     | 
    
         
            -
                    service(:storage,  
     | 
| 
      
 14 
     | 
    
         
            +
                    service(:storage, "Storage")
         
     | 
| 
       16 
15 
     | 
    
         
             
                  end
         
     | 
| 
       17 
16 
     | 
    
         
             
                end
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
18 
     | 
    
         
             
                module Fog
         
     | 
| 
       20 
19 
     | 
    
         
             
                  module Storage
         
     | 
| 
       21 
20 
     | 
    
         
             
                    class TheRightWay
         
     | 
| 
       22 
     | 
    
         
            -
                      def initialize( 
     | 
| 
      
 21 
     | 
    
         
            +
                      def initialize(_args); end
         
     | 
| 
       23 
22 
     | 
    
         
             
                    end
         
     | 
| 
       24 
23 
     | 
    
         
             
                  end
         
     | 
| 
       25 
24 
     | 
    
         
             
                end
         
     | 
| 
         @@ -29,18 +28,17 @@ describe "Fog::Storage" do 
     | 
|
| 
       29 
28 
     | 
    
         
             
                  assert_instance_of(Fog::Storage::TheRightWay, compute)
         
     | 
| 
       30 
29 
     | 
    
         
             
                end
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
31 
     | 
    
         
             
                module Fog
         
     | 
| 
       34 
32 
     | 
    
         
             
                  module TheWrongWay
         
     | 
| 
       35 
33 
     | 
    
         
             
                    extend Provider
         
     | 
| 
       36 
     | 
    
         
            -
                    service(:storage,  
     | 
| 
      
 34 
     | 
    
         
            +
                    service(:storage, "Storage")
         
     | 
| 
       37 
35 
     | 
    
         
             
                  end
         
     | 
| 
       38 
36 
     | 
    
         
             
                end
         
     | 
| 
       39 
37 
     | 
    
         | 
| 
       40 
38 
     | 
    
         
             
                module Fog
         
     | 
| 
       41 
39 
     | 
    
         
             
                  module TheWrongWay
         
     | 
| 
       42 
40 
     | 
    
         
             
                    class Storage
         
     | 
| 
       43 
     | 
    
         
            -
                      def initialize( 
     | 
| 
      
 41 
     | 
    
         
            +
                      def initialize(_args); end
         
     | 
| 
       44 
42 
     | 
    
         
             
                    end
         
     | 
| 
       45 
43 
     | 
    
         
             
                  end
         
     | 
| 
       46 
44 
     | 
    
         
             
                end
         
     | 
| 
         @@ -53,14 +51,14 @@ describe "Fog::Storage" do 
     | 
|
| 
       53 
51 
     | 
    
         
             
                module Fog
         
     | 
| 
       54 
52 
     | 
    
         
             
                  module BothWays
         
     | 
| 
       55 
53 
     | 
    
         
             
                    extend Provider
         
     | 
| 
       56 
     | 
    
         
            -
                    service(:storage,  
     | 
| 
      
 54 
     | 
    
         
            +
                    service(:storage, "Storage")
         
     | 
| 
       57 
55 
     | 
    
         
             
                  end
         
     | 
| 
       58 
56 
     | 
    
         
             
                end
         
     | 
| 
       59 
57 
     | 
    
         | 
| 
       60 
58 
     | 
    
         
             
                module Fog
         
     | 
| 
       61 
59 
     | 
    
         
             
                  module BothWays
         
     | 
| 
       62 
60 
     | 
    
         
             
                    class Storage
         
     | 
| 
       63 
     | 
    
         
            -
                      def initialize( 
     | 
| 
      
 61 
     | 
    
         
            +
                      def initialize(_args); end
         
     | 
| 
       64 
62 
     | 
    
         
             
                    end
         
     | 
| 
       65 
63 
     | 
    
         
             
                  end
         
     | 
| 
       66 
64 
     | 
    
         
             
                end
         
     | 
| 
         @@ -82,16 +80,30 @@ describe "Fog::Storage" do 
     | 
|
| 
       82 
80 
     | 
    
         
             
                    assert_instance_of(Fog::Storage::BothWays, compute)
         
     | 
| 
       83 
81 
     | 
    
         
             
                  end
         
     | 
| 
       84 
82 
     | 
    
         
             
                end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
       86 
84 
     | 
    
         
             
                it "passes the supplied keyword args less :provider to Fog::Storage::<Provider>#new" do
         
     | 
| 
       87 
85 
     | 
    
         
             
                  compute = Fog::Storage.new(:provider => :bothways, :extra => :stuff)
         
     | 
| 
       88 
     | 
    
         
            -
                  assert_equal({:extra => :stuff}, compute.args)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  assert_equal({ :extra => :stuff }, compute.args)
         
     | 
| 
       89 
87 
     | 
    
         
             
                end
         
     | 
| 
       90 
88 
     | 
    
         | 
| 
       91 
89 
     | 
    
         
             
                it "raises ArgumentError when given a :provider where a Fog::Storage::Provider that does not exist" do
         
     | 
| 
       92 
90 
     | 
    
         
             
                  assert_raises(ArgumentError) do
         
     | 
| 
       93 
91 
     | 
    
         
             
                    Fog::Storage.new(:provider => :wat)
         
     | 
| 
       94 
92 
     | 
    
         
             
                  end
         
     | 
| 
       95 
     | 
    
         
            -
                end 
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              describe ".get_body_size" do
         
     | 
| 
      
 97 
     | 
    
         
            +
                current_version = Gem::Version.new(RUBY_VERSION)
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                # Ruby 1.8 doesn't support string encodings, so we can't test that
         
     | 
| 
      
 100 
     | 
    
         
            +
                if current_version >= Gem::Version.new("1.9.0")
         
     | 
| 
      
 101 
     | 
    
         
            +
                  it "doesn't alter the encoding of the string passed to it" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                    body = "foo".encode("UTF-8")
         
     | 
| 
      
 103 
     | 
    
         
            +
                    Fog::Storage.get_body_size(body)
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                    assert_equal("UTF-8", body.encoding.to_s)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
       96 
108 
     | 
    
         
             
              end
         
     | 
| 
       97 
109 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "fog/test_helpers/formats_helper"
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            module Shindo
         
     | 
| 
       5 
5 
     | 
    
         
             
              class Tests
         
     | 
| 
       6 
     | 
    
         
            -
                def test( 
     | 
| 
      
 6 
     | 
    
         
            +
                def test(_str, &_block)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  yield
         
     | 
| 
       8 
8 
     | 
    
         
             
                end
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
         @@ -11,110 +11,110 @@ end 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            describe "formats_helper" do
         
     | 
| 
       13 
13 
     | 
    
         
             
              let(:shindo) { Shindo::Tests.new }
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              it  
     | 
| 
       16 
     | 
    
         
            -
                data = {:welcome => "Hello" }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              it "comparing welcome data against schema" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                data = { :welcome => "Hello" }
         
     | 
| 
       17 
17 
     | 
    
         
             
                assert shindo.data_matches_schema(:welcome => String) { data }
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
              describe  
     | 
| 
       21 
     | 
    
         
            -
                it  
     | 
| 
       22 
     | 
    
         
            -
                  assert shindo.data_matches_schema( 
     | 
| 
      
 20 
     | 
    
         
            +
              describe "#data_matches_schema" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                it "when value matches schema expectation" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  assert shindo.data_matches_schema("key" => String) { { "key" => "Value" } }
         
     | 
| 
       23 
23 
     | 
    
         
             
                end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                it  
     | 
| 
       26 
     | 
    
         
            -
                  assert shindo.data_matches_schema( 
     | 
| 
      
 25 
     | 
    
         
            +
                it "when values within an array all match schema expectation" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  assert shindo.data_matches_schema("key" => [Integer]) { { "key" => [1, 2] } }
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                it  
     | 
| 
       30 
     | 
    
         
            -
                  assert shindo.data_matches_schema( 
     | 
| 
      
 29 
     | 
    
         
            +
                it "when nested values match schema expectation" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  assert shindo.data_matches_schema("key" => { :nested_key => String }) { { "key" => { :nested_key => "Value" } } }
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                it  
     | 
| 
       34 
     | 
    
         
            -
                  assert shindo.data_matches_schema([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] }
         
     | 
| 
      
 33 
     | 
    
         
            +
                it "when collection of values all match schema expectation" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  assert shindo.data_matches_schema([{ "key" => String }]) { [{ "key" => "Value" }, { "key" => "Value" }] }
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                it  
     | 
| 
       38 
     | 
    
         
            -
                  assert shindo.data_matches_schema([{"key" => String}],  
     | 
| 
      
 37 
     | 
    
         
            +
                it "when collection is empty although schema covers optional members" do
         
     | 
| 
      
 38 
     | 
    
         
            +
                  assert shindo.data_matches_schema([{ "key" => String }], :allow_optional_rules => true) { [] }
         
     | 
| 
       39 
39 
     | 
    
         
             
                end
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                it  
     | 
| 
       42 
     | 
    
         
            -
                  assert shindo.data_matches_schema({"key" => String}, {:allow_extra_keys => true}) { {"key" => "Value", :extra => "Bonus"} }
         
     | 
| 
      
 41 
     | 
    
         
            +
                it "when additional keys are passed and not strict" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                  assert shindo.data_matches_schema({ "key" => String }, { :allow_extra_keys => true }) { { "key" => "Value", :extra => "Bonus" } }
         
     | 
| 
       43 
43 
     | 
    
         
             
                end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
                it  
     | 
| 
       46 
     | 
    
         
            -
                  assert shindo.data_matches_schema( 
     | 
| 
      
 45 
     | 
    
         
            +
                it "when value is nil and schema expects NilClass" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  assert shindo.data_matches_schema("key" => NilClass) { { "key" => nil } }
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                it  
     | 
| 
      
 49 
     | 
    
         
            +
                it "when value and schema match as hashes" do
         
     | 
| 
       50 
50 
     | 
    
         
             
                  assert shindo.data_matches_schema({}) { {} }
         
     | 
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                it  
     | 
| 
      
 53 
     | 
    
         
            +
                it "when value and schema match as arrays" do
         
     | 
| 
       54 
54 
     | 
    
         
             
                  assert shindo.data_matches_schema([]) { [] }
         
     | 
| 
       55 
55 
     | 
    
         
             
                end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
                it  
     | 
| 
       58 
     | 
    
         
            -
                  assert shindo.data_matches_schema( 
     | 
| 
      
 57 
     | 
    
         
            +
                it "when value is a Time" do
         
     | 
| 
      
 58 
     | 
    
         
            +
                  assert shindo.data_matches_schema("time" => Time) { { "time" => Time.now } }
         
     | 
| 
       59 
59 
     | 
    
         
             
                end
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                it  
     | 
| 
       62 
     | 
    
         
            -
                  assert shindo.data_matches_schema({"key" => NilClass}, {:allow_optional_rules => true}) { {} }
         
     | 
| 
      
 61 
     | 
    
         
            +
                it "when key is missing but value should be NilClass (#1477)" do
         
     | 
| 
      
 62 
     | 
    
         
            +
                  assert shindo.data_matches_schema({ "key" => NilClass }, { :allow_optional_rules => true }) { {} }
         
     | 
| 
       63 
63 
     | 
    
         
             
                end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
                it  
     | 
| 
       66 
     | 
    
         
            -
                  assert shindo.data_matches_schema({"key" => Fog::Nullable::String}, {:allow_optional_rules => true}) { {} }
         
     | 
| 
      
 65 
     | 
    
         
            +
                it "when key is missing but value is nullable (#1477)" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                  assert shindo.data_matches_schema({ "key" => Fog::Nullable::String }, { :allow_optional_rules => true }) { {} }
         
     | 
| 
       67 
67 
     | 
    
         
             
                end
         
     | 
| 
       68 
68 
     | 
    
         
             
              end
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
     | 
    
         
            -
              describe  
     | 
| 
      
 70 
     | 
    
         
            +
              describe "#formats backwards compatible changes" do
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                it  
     | 
| 
       73 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 72 
     | 
    
         
            +
                it "when value matches schema expectation" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                  assert shindo.formats("key" => String) { { "key" => "Value" } }
         
     | 
| 
       74 
74 
     | 
    
         
             
                end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
                it  
     | 
| 
       77 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 76 
     | 
    
         
            +
                it "when values within an array all match schema expectation" do
         
     | 
| 
      
 77 
     | 
    
         
            +
                  assert shindo.formats("key" => [Integer]) { { "key" => [1, 2] } }
         
     | 
| 
       78 
78 
     | 
    
         
             
                end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
     | 
    
         
            -
                it  
     | 
| 
       81 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 80 
     | 
    
         
            +
                it "when nested values match schema expectation" do
         
     | 
| 
      
 81 
     | 
    
         
            +
                  assert shindo.formats("key" => { :nested_key => String }) { { "key" => { :nested_key => "Value" } } }
         
     | 
| 
       82 
82 
     | 
    
         
             
                end
         
     | 
| 
       83 
83 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
                it  
     | 
| 
       85 
     | 
    
         
            -
                  assert shindo.formats([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] }
         
     | 
| 
      
 84 
     | 
    
         
            +
                it "when collection of values all match schema expectation" do
         
     | 
| 
      
 85 
     | 
    
         
            +
                  assert shindo.formats([{ "key" => String }]) { [{ "key" => "Value" }, { "key" => "Value" }] }
         
     | 
| 
       86 
86 
     | 
    
         
             
                end
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
                it  
     | 
| 
       89 
     | 
    
         
            -
                  assert shindo.formats([{"key" => String}]) { [] }
         
     | 
| 
      
 88 
     | 
    
         
            +
                it "when collection is empty although schema covers optional members" do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  assert shindo.formats([{ "key" => String }]) { [] }
         
     | 
| 
       90 
90 
     | 
    
         
             
                end
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
                it  
     | 
| 
       93 
     | 
    
         
            -
                  assert shindo.formats({"key" => String}, false) { {"key" => "Value", :extra => "Bonus"} }
         
     | 
| 
      
 92 
     | 
    
         
            +
                it "when additional keys are passed and not strict" do
         
     | 
| 
      
 93 
     | 
    
         
            +
                  assert shindo.formats({ "key" => String }, false) { { "key" => "Value", :extra => "Bonus" } }
         
     | 
| 
       94 
94 
     | 
    
         
             
                end
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
                it  
     | 
| 
       97 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 96 
     | 
    
         
            +
                it "when value is nil and schema expects NilClass" do
         
     | 
| 
      
 97 
     | 
    
         
            +
                  assert shindo.formats("key" => NilClass) { { "key" => nil } }
         
     | 
| 
       98 
98 
     | 
    
         
             
                end
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
                it  
     | 
| 
      
 100 
     | 
    
         
            +
                it "when value and schema match as hashes" do
         
     | 
| 
       101 
101 
     | 
    
         
             
                  assert shindo.formats({}) { {} }
         
     | 
| 
       102 
102 
     | 
    
         
             
                end
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                it  
     | 
| 
      
 104 
     | 
    
         
            +
                it "when value and schema match as arrays" do
         
     | 
| 
       105 
105 
     | 
    
         
             
                  assert shindo.formats([]) { [] }
         
     | 
| 
       106 
106 
     | 
    
         
             
                end
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
                it  
     | 
| 
       109 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 108 
     | 
    
         
            +
                it "when value is a Time" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                  assert shindo.formats("time" => Time) { { "time" => Time.now } }
         
     | 
| 
       110 
110 
     | 
    
         
             
                end
         
     | 
| 
       111 
111 
     | 
    
         | 
| 
       112 
     | 
    
         
            -
                it  
     | 
| 
       113 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 112 
     | 
    
         
            +
                it "when key is missing but value should be NilClass (#1477)" do
         
     | 
| 
      
 113 
     | 
    
         
            +
                  assert shindo.formats("key" => NilClass) { {} }
         
     | 
| 
       114 
114 
     | 
    
         
             
                end
         
     | 
| 
       115 
115 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                it  
     | 
| 
       117 
     | 
    
         
            -
                  assert shindo.formats( 
     | 
| 
      
 116 
     | 
    
         
            +
                it "when key is missing but value is nullable (#1477)" do
         
     | 
| 
      
 117 
     | 
    
         
            +
                  assert shindo.formats("key" => Fog::Nullable::String) { {} }
         
     | 
| 
       118 
118 
     | 
    
         
             
                end
         
     | 
| 
       119 
119 
     | 
    
         
             
              end
         
     | 
| 
       120 
120 
     | 
    
         
             
            end
         
     |