aws-sessionstore-dynamodb 1.0.0 → 2.0.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 (50) hide show
  1. checksums.yaml +5 -5
  2. data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
  3. data/.gitignore +1 -0
  4. data/.gitmodules +3 -0
  5. data/.travis.yml +16 -5
  6. data/.yardopts +3 -2
  7. data/CHANGELOG.md +24 -0
  8. data/CODE_OF_CONDUCT.md +4 -0
  9. data/CONTRIBUTING.md +61 -0
  10. data/Gemfile +7 -19
  11. data/{LICENSE.txt → LICENSE} +0 -0
  12. data/README.md +17 -63
  13. data/Rakefile +37 -14
  14. data/VERSION +1 -0
  15. data/aws-sessionstore-dynamodb.gemspec +7 -5
  16. data/doc-src/templates/default/layout/html/footer.erb +10 -0
  17. data/doc-src/templates/default/layout/html/layout.erb +31 -0
  18. data/lib/aws-sessionstore-dynamodb.rb +0 -15
  19. data/lib/aws/session_store/dynamo_db/configuration.rb +2 -29
  20. data/lib/aws/session_store/dynamo_db/errors/base_handler.rb +0 -14
  21. data/lib/aws/session_store/dynamo_db/errors/default_handler.rb +0 -14
  22. data/lib/aws/session_store/dynamo_db/garbage_collection.rb +2 -15
  23. data/lib/aws/session_store/dynamo_db/invalid_id_error.rb +0 -14
  24. data/lib/aws/session_store/dynamo_db/lock_wait_timeout_error.rb +0 -14
  25. data/lib/aws/session_store/dynamo_db/locking/base.rb +14 -17
  26. data/lib/aws/session_store/dynamo_db/locking/null.rb +0 -14
  27. data/lib/aws/session_store/dynamo_db/locking/pessimistic.rb +0 -16
  28. data/lib/aws/session_store/dynamo_db/missing_secret_key_error.rb +0 -14
  29. data/lib/aws/session_store/dynamo_db/rack_middleware.rb +11 -24
  30. data/lib/aws/session_store/dynamo_db/table.rb +1 -14
  31. data/lib/aws/session_store/dynamo_db/version.rb +1 -15
  32. data/spec/aws/session_store/dynamo_db/app_config.yml +6 -6
  33. data/spec/aws/session_store/dynamo_db/configuration_spec.rb +28 -51
  34. data/spec/aws/session_store/dynamo_db/error/default_error_handler_spec.rb +23 -21
  35. data/spec/aws/session_store/dynamo_db/garbage_collection_spec.rb +68 -69
  36. data/spec/aws/session_store/dynamo_db/locking/threaded_sessions_spec.rb +17 -16
  37. data/spec/aws/session_store/dynamo_db/rack_middleware_database_spec.rb +47 -46
  38. data/spec/aws/session_store/dynamo_db/rack_middleware_spec.rb +59 -61
  39. data/spec/aws/session_store/dynamo_db/table_spec.rb +9 -7
  40. data/spec/spec_helper.rb +14 -11
  41. metadata +27 -29
  42. data/lib/aws/session_store/dynamo_db/railtie.rb +0 -28
  43. data/lib/aws/session_store/dynamo_db/tasks/session_table.rake +0 -21
  44. data/lib/rails/generators/sessionstore/dynamodb/dynamodb_generator.rb +0 -55
  45. data/lib/rails/generators/sessionstore/dynamodb/templates/sessionstore/USAGE +0 -13
  46. data/lib/rails/generators/sessionstore/dynamodb/templates/sessionstore/dynamodb.yml +0 -71
  47. data/lib/rails/generators/sessionstore/dynamodb/templates/sessionstore_migration.rb +0 -10
  48. data/spec/aws/session_store/dynamo_db/config/dynamo_db_session.yml +0 -24
  49. data/spec/aws/session_store/dynamo_db/rails_app_config.yml +0 -24
  50. data/tasks/test.rake +0 -29
@@ -1,18 +1,5 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
1
  require 'yaml'
15
- require 'aws-sdk'
2
+ require 'aws-sdk-dynamodb'
16
3
 
17
4
  module Aws::SessionStore::DynamoDB
18
5
  # This class provides a Configuration object for all DynamoDB transactions
@@ -240,24 +227,15 @@ module Aws::SessionStore::DynamoDB
240
227
  file_path = config_file_path(options)
241
228
  if file_path
242
229
  load_from_file(file_path)
243
- elsif rails_defined && File.exists?(rails_config_file_path)
244
- load_from_file(rails_config_file_path)
245
230
  else
246
231
  {}
247
232
  end
248
233
  end
249
234
 
250
- # @return [Boolean] Necessary Rails variables defined.
251
- def rails_defined
252
- defined?(Rails) && defined?(Rails.root) && defined?(Rails.env)
253
- end
254
-
255
- # Load options from YAML file depending on existence of Rails
256
- # and possible development stage defined.
235
+ # Load options from YAML file
257
236
  def load_from_file(file_path)
258
237
  require "erb"
259
238
  opts = YAML.load(ERB.new(File.read(file_path)).result) || {}
260
- opts = opts[Rails.env] if rails_defined && opts.key?(Rails.env)
261
239
  symbolize_keys(opts)
262
240
  end
263
241
 
@@ -266,11 +244,6 @@ module Aws::SessionStore::DynamoDB
266
244
  options[:config_file] || ENV["DYNAMO_DB_SESSION_CONFIG_FILE"]
267
245
  end
268
246
 
269
- # @return [String] Rails configuraton path to YAML file default.
270
- def rails_config_file_path
271
- File.join(Rails.root, "config", "sessionstore/dynamodb.yml")
272
- end
273
-
274
247
  # Set accessible attributes after merged options.
275
248
  def set_attributes(options)
276
249
  @options.keys.each do |opt_name|
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB::Errors
16
2
  # BaseErrorHandler provides an interface for error handlers
17
3
  # that can be passed in to {Aws::SessionStore::DynamoDB::RackMiddleware}.
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB::Errors
16
2
  # This class handles errors raised from DynamoDB.
17
3
  class DefaultHandler < Aws::SessionStore::DynamoDB::Errors::BaseHandler
@@ -1,17 +1,4 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- require 'aws-sdk'
1
+ require 'aws-sdk-dynamodb'
15
2
 
16
3
  module Aws::SessionStore::DynamoDB
17
4
  # Collects and deletes unwanted sessions based on
@@ -50,7 +37,7 @@ module Aws::SessionStore::DynamoDB
50
37
  # @api private
51
38
  def eliminate_unwanted_sessions(config, last_key = nil)
52
39
  scan_result = scan(config, last_key)
53
- batch_delete(config, scan_result[:member])
40
+ batch_delete(config, scan_result[:items])
54
41
  scan_result[:last_evaluated_key] || {}
55
42
  end
56
43
 
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB
16
2
  class InvalidIDError < RuntimeError
17
3
  def initialize(msg = "Corrupt Session ID!")
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB
16
2
  class LockWaitTimeoutError < RuntimeError
17
3
  def initialize(msg = 'Maximum time spent to acquire lock has been exceeded!')
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB::Locking
16
2
  # This class provides a framework for implementing
17
3
  # locking strategies.
@@ -65,7 +51,7 @@ module Aws::SessionStore::DynamoDB::Locking
65
51
 
66
52
  # @return [Hash] Options for deleting session.
67
53
  def delete_opts(sid)
68
- merge_all(table_opts(sid), expected_attributes(sid))
54
+ table_opts(sid)
69
55
  end
70
56
 
71
57
  # @return [Hash] Options for updating item in Session table.
@@ -109,8 +95,8 @@ module Aws::SessionStore::DynamoDB::Locking
109
95
  def attr_updts(env, session, add_attrs = {})
110
96
  data = data_unchanged?(env, session) ? {} : data_attr(session)
111
97
  {
112
- :attribute_updates => merge_all(updated_attr, data, add_attrs),
113
- :return_values => "UPDATED_NEW"
98
+ attribute_updates: merge_all(updated_attr, data, add_attrs, expire_attr),
99
+ return_values: 'UPDATED_NEW'
114
100
  }
115
101
  end
116
102
 
@@ -124,6 +110,17 @@ module Aws::SessionStore::DynamoDB::Locking
124
110
  { "created_at" => updated_at }
125
111
  end
126
112
 
113
+ # Update client with current time + max_stale.
114
+ def expire_at
115
+ max_stale = @config.max_stale || 0
116
+ { value: (Time.now + max_stale).to_i, action: 'PUT' }
117
+ end
118
+
119
+ # Attribute for TTL expiration of session.
120
+ def expire_attr
121
+ { 'expire_at' => expire_at }
122
+ end
123
+
127
124
  # Attribute for updating session.
128
125
  def updated_attr
129
126
  {
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB::Locking
16
2
  # This class gets and sets sessions
17
3
  # without a locking strategy.
@@ -1,24 +1,8 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB::Locking
16
2
  # This class implements a pessimistic locking strategy for the
17
3
  # DynamoDB session handler. Sessions obtain an exclusive lock
18
4
  # for reads that is only released when the session is saved.
19
5
  class Pessimistic < Aws::SessionStore::DynamoDB::Locking::Base
20
- WAIT_ERROR =
21
-
22
6
  # Saves the session.
23
7
  def set_session_data(env, sid, session, options = {})
24
8
  super(env, sid, session, set_lock_options(env, options))
@@ -1,17 +1,3 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws::SessionStore::DynamoDB
16
2
  class MissingSecretKeyError < RuntimeError
17
3
  def initialize(msg = "No secret key provided!")
@@ -1,24 +1,11 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
1
  require 'rack/session/abstract/id'
15
2
  require 'openssl'
16
- require 'aws-sdk'
3
+ require 'aws-sdk-dynamodb'
17
4
 
18
5
  module Aws::SessionStore::DynamoDB
19
6
  # This class is an ID based Session Store Rack Middleware
20
7
  # that uses a DynamoDB backend for session storage.
21
- class RackMiddleware < Rack::Session::Abstract::ID
8
+ class RackMiddleware < Rack::Session::Abstract::Persisted
22
9
 
23
10
  # Initializes SessionStore middleware.
24
11
  #
@@ -58,16 +45,16 @@ module Aws::SessionStore::DynamoDB
58
45
  end
59
46
 
60
47
  # Gets session data.
61
- def get_session(env, sid)
48
+ def find_session(req, sid)
62
49
  validate_config
63
50
  case verify_hmac(sid)
64
51
  when nil
65
- set_new_session_properties(env)
52
+ set_new_session_properties(req.env)
66
53
  when false
67
- handle_error {raise InvalidIDError}
68
- set_new_session_properties(env)
54
+ handle_error { raise InvalidIDError }
55
+ set_new_session_properties(req.env)
69
56
  else
70
- data = @lock.get_session_data(env, sid)
57
+ data = @lock.get_session_data(req.env, sid)
71
58
  [sid, data || {}]
72
59
  end
73
60
  end
@@ -81,15 +68,15 @@ module Aws::SessionStore::DynamoDB
81
68
  #
82
69
  # @return [Hash] If session has been saved.
83
70
  # @return [false] If session has could not be saved.
84
- def set_session(env, sid, session, options)
85
- @lock.set_session_data(env, sid, session, options)
71
+ def write_session(req, sid, session, options)
72
+ @lock.set_session_data(req.env, sid, session, options)
86
73
  end
87
74
 
88
75
  # Destroys session and removes session from database.
89
76
  #
90
77
  # @return [String] return a new session id or nil if options[:drop]
91
- def destroy_session(env, sid, options)
92
- @lock.delete_session(env, sid)
78
+ def delete_session(req, sid, options)
79
+ @lock.delete_session(req.env, sid)
93
80
  generate_sid unless options[:drop]
94
81
  end
95
82
 
@@ -1,17 +1,4 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- require 'aws-sdk'
1
+ require 'aws-sdk-dynamodb'
15
2
  require 'logger'
16
3
 
17
4
  module Aws::SessionStore::DynamoDB
@@ -1,21 +1,7 @@
1
- # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
-
15
1
  module Aws
16
2
  module SessionStore
17
3
  module DynamoDB
18
- VERSION = "1.0.0"
4
+ VERSION = "2.0.0"
19
5
  end
20
6
  end
21
7
  end
@@ -11,9 +11,9 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- table_name: NewTable
15
- table_key: Somekey
16
- consistent_read: true
17
- AWS_ACCESS_KEY_ID: FakeKey
18
- AWS_SECRET_ACCESS_KEY: Secret
19
- AWS_REGION: New York
14
+ table_name: NewTable
15
+ table_key: Somekey
16
+ consistent_read: true
17
+ AWS_ACCESS_KEY_ID: FakeKey
18
+ AWS_SECRET_ACCESS_KEY: Secret
19
+ AWS_REGION: New York
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License"). You
@@ -11,91 +13,66 @@
11
13
  # ANY KIND, either express or implied. See the License for the specific
12
14
  # language governing permissions and limitations under the License.
13
15
 
14
- require "spec_helper"
16
+ require 'spec_helper'
15
17
 
16
18
  describe Aws::SessionStore::DynamoDB::Configuration do
17
-
18
19
  let(:defaults) do
19
20
  {
20
- :table_name => "sessions",
21
- :table_key => "session_id",
22
- :consistent_read => true,
23
- :read_capacity => 10,
24
- :write_capacity => 5,
25
- :raise_errors => false
21
+ table_name: 'sessions',
22
+ table_key: 'session_id',
23
+ consistent_read: true,
24
+ read_capacity: 10,
25
+ write_capacity: 5,
26
+ raise_errors: false
26
27
  }
27
28
  end
28
29
 
29
30
  let(:expected_file_opts) do
30
31
  {
31
- :consistent_read => true,
32
- :AWS_ACCESS_KEY_ID => 'FakeKey',
33
- :AWS_REGION => 'New York',
34
- :table_name => 'NewTable',
35
- :table_key => 'Somekey',
36
- :AWS_SECRET_ACCESS_KEY => 'Secret'
32
+ consistent_read: true,
33
+ AWS_ACCESS_KEY_ID: 'FakeKey',
34
+ AWS_REGION: 'New York',
35
+ table_name: 'NewTable',
36
+ table_key: 'Somekey',
37
+ AWS_SECRET_ACCESS_KEY: 'Secret'
37
38
  }
38
39
  end
39
40
 
40
41
  let(:runtime_options) do
41
42
  {
42
- :table_name => "SessionTable",
43
- :table_key => "session_id_stuff"
43
+ table_name: 'SessionTable',
44
+ table_key: 'session_id_stuff'
44
45
  }
45
46
  end
46
47
 
47
48
  def expected_options(opts)
48
49
  cfg = Aws::SessionStore::DynamoDB::Configuration.new(opts)
49
50
  expected_opts = defaults.merge(expected_file_opts).merge(opts)
50
- cfg.to_hash.should include(expected_opts)
51
+ expect(cfg.to_hash).to include(expected_opts)
51
52
  end
52
53
 
53
- context "Configuration Tests" do
54
- it "configures option with out runtime,YAML or ENV options" do
54
+ context 'Configuration Tests' do
55
+ it 'configures option with out runtime,YAML or ENV options' do
55
56
  cfg = Aws::SessionStore::DynamoDB::Configuration.new
56
- cfg.to_hash.should include(defaults)
57
+ expect(cfg.to_hash).to include(defaults)
57
58
  end
58
59
 
59
- it "configures accurate option hash with runtime options, no YAML or ENV" do
60
+ it 'configures accurate option hash with runtime options, no YAML or ENV' do
60
61
  cfg = Aws::SessionStore::DynamoDB::Configuration.new(runtime_options)
61
62
  expected_opts = defaults.merge(runtime_options)
62
- cfg.to_hash.should include(expected_opts)
63
+ expect(cfg.to_hash).to include(expected_opts)
63
64
  end
64
65
 
65
- it "merge YAML and runtime options giving runtime precendence" do
66
+ it 'merge YAML and runtime options giving runtime precendence' do
66
67
  config_path = File.dirname(__FILE__) + '/app_config.yml'
67
- runtime_opts = {:config_file => config_path}.merge(runtime_options)
68
+ runtime_opts = { config_file: config_path }.merge(runtime_options)
68
69
  expected_options(runtime_opts)
69
70
  end
70
71
 
71
- it "loads options from YAML file based on Rails environment" do
72
- rails = double('Rails', {:env => 'test', :root => ''})
73
- stub_const("Rails", rails)
74
- config_path = File.dirname(__FILE__) + '/rails_app_config.yml'
75
- runtime_opts = {:config_file => config_path}.merge(runtime_options)
76
- expected_options(runtime_opts)
77
- end
78
-
79
- it "has rails defiend but no file specified, no error thrown" do
80
- rails = double('Rails', {:env => 'test', :root => ''})
81
- stub_const("Rails", rails)
82
- cfg = Aws::SessionStore::DynamoDB::Configuration.new(runtime_options)
83
- expected_opts = defaults.merge(runtime_options)
84
- cfg.to_hash.should include(expected_opts)
85
- end
86
-
87
- it "has rails defiend but and default rails YAML file loads" do
88
- rails = double('Rails', {:env => 'test', :root => File.dirname(__FILE__)})
89
- stub_const("Rails", rails)
90
- cfg = Aws::SessionStore::DynamoDB::Configuration.new(runtime_options)
91
- expected_opts = defaults.merge(runtime_options)
92
- cfg.to_hash.should include(expected_opts)
93
- end
94
-
95
- it "throws an exception when wrong path for file" do
72
+ it 'throws an exception when wrong path for file' do
96
73
  config_path = 'Wrong path!'
97
- runtime_opts = {:config_file => config_path}.merge(runtime_options)
98
- expect{cfg = Aws::SessionStore::DynamoDB::Configuration.new(runtime_opts)}.to raise_error(Errno::ENOENT)
74
+ runtime_opts = { config_file: config_path }.merge(runtime_options)
75
+ expect { cfg = Aws::SessionStore::DynamoDB::Configuration.new(runtime_opts) }.to raise_error(Errno::ENOENT)
99
76
  end
100
77
  end
101
78
  end