powerhome-scimitar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +708 -0
  4. data/Rakefile +16 -0
  5. data/app/controllers/scimitar/active_record_backed_resources_controller.rb +257 -0
  6. data/app/controllers/scimitar/application_controller.rb +157 -0
  7. data/app/controllers/scimitar/resource_types_controller.rb +28 -0
  8. data/app/controllers/scimitar/resources_controller.rb +203 -0
  9. data/app/controllers/scimitar/schemas_controller.rb +21 -0
  10. data/app/controllers/scimitar/service_provider_configurations_controller.rb +8 -0
  11. data/app/models/scimitar/authentication_error.rb +9 -0
  12. data/app/models/scimitar/authentication_scheme.rb +18 -0
  13. data/app/models/scimitar/bulk.rb +8 -0
  14. data/app/models/scimitar/complex_types/address.rb +12 -0
  15. data/app/models/scimitar/complex_types/base.rb +83 -0
  16. data/app/models/scimitar/complex_types/email.rb +12 -0
  17. data/app/models/scimitar/complex_types/entitlement.rb +12 -0
  18. data/app/models/scimitar/complex_types/ims.rb +12 -0
  19. data/app/models/scimitar/complex_types/name.rb +12 -0
  20. data/app/models/scimitar/complex_types/phone_number.rb +12 -0
  21. data/app/models/scimitar/complex_types/photo.rb +12 -0
  22. data/app/models/scimitar/complex_types/reference_group.rb +12 -0
  23. data/app/models/scimitar/complex_types/reference_member.rb +12 -0
  24. data/app/models/scimitar/complex_types/role.rb +12 -0
  25. data/app/models/scimitar/complex_types/x509_certificate.rb +12 -0
  26. data/app/models/scimitar/engine_configuration.rb +32 -0
  27. data/app/models/scimitar/error_response.rb +32 -0
  28. data/app/models/scimitar/errors.rb +14 -0
  29. data/app/models/scimitar/filter.rb +11 -0
  30. data/app/models/scimitar/filter_error.rb +22 -0
  31. data/app/models/scimitar/invalid_syntax_error.rb +9 -0
  32. data/app/models/scimitar/lists/count.rb +64 -0
  33. data/app/models/scimitar/lists/query_parser.rb +745 -0
  34. data/app/models/scimitar/meta.rb +7 -0
  35. data/app/models/scimitar/not_found_error.rb +10 -0
  36. data/app/models/scimitar/resource_invalid_error.rb +9 -0
  37. data/app/models/scimitar/resource_type.rb +29 -0
  38. data/app/models/scimitar/resources/base.rb +190 -0
  39. data/app/models/scimitar/resources/group.rb +13 -0
  40. data/app/models/scimitar/resources/mixin.rb +1524 -0
  41. data/app/models/scimitar/resources/user.rb +13 -0
  42. data/app/models/scimitar/schema/address.rb +25 -0
  43. data/app/models/scimitar/schema/attribute.rb +132 -0
  44. data/app/models/scimitar/schema/base.rb +90 -0
  45. data/app/models/scimitar/schema/derived_attributes.rb +24 -0
  46. data/app/models/scimitar/schema/email.rb +10 -0
  47. data/app/models/scimitar/schema/entitlement.rb +10 -0
  48. data/app/models/scimitar/schema/group.rb +27 -0
  49. data/app/models/scimitar/schema/ims.rb +10 -0
  50. data/app/models/scimitar/schema/name.rb +20 -0
  51. data/app/models/scimitar/schema/phone_number.rb +10 -0
  52. data/app/models/scimitar/schema/photo.rb +10 -0
  53. data/app/models/scimitar/schema/reference_group.rb +23 -0
  54. data/app/models/scimitar/schema/reference_member.rb +21 -0
  55. data/app/models/scimitar/schema/role.rb +10 -0
  56. data/app/models/scimitar/schema/user.rb +52 -0
  57. data/app/models/scimitar/schema/vdtp.rb +18 -0
  58. data/app/models/scimitar/schema/x509_certificate.rb +22 -0
  59. data/app/models/scimitar/service_provider_configuration.rb +60 -0
  60. data/app/models/scimitar/supportable.rb +14 -0
  61. data/app/views/layouts/scimitar/application.html.erb +14 -0
  62. data/config/initializers/scimitar.rb +111 -0
  63. data/config/routes.rb +6 -0
  64. data/lib/scimitar/engine.rb +63 -0
  65. data/lib/scimitar/support/hash_with_indifferent_case_insensitive_access.rb +216 -0
  66. data/lib/scimitar/support/utilities.rb +51 -0
  67. data/lib/scimitar/version.rb +13 -0
  68. data/lib/scimitar.rb +29 -0
  69. data/spec/apps/dummy/app/controllers/custom_create_mock_users_controller.rb +25 -0
  70. data/spec/apps/dummy/app/controllers/custom_destroy_mock_users_controller.rb +24 -0
  71. data/spec/apps/dummy/app/controllers/custom_replace_mock_users_controller.rb +25 -0
  72. data/spec/apps/dummy/app/controllers/custom_request_verifiers_controller.rb +30 -0
  73. data/spec/apps/dummy/app/controllers/custom_save_mock_users_controller.rb +24 -0
  74. data/spec/apps/dummy/app/controllers/custom_update_mock_users_controller.rb +25 -0
  75. data/spec/apps/dummy/app/controllers/mock_groups_controller.rb +13 -0
  76. data/spec/apps/dummy/app/controllers/mock_users_controller.rb +13 -0
  77. data/spec/apps/dummy/app/models/mock_group.rb +83 -0
  78. data/spec/apps/dummy/app/models/mock_user.rb +132 -0
  79. data/spec/apps/dummy/config/application.rb +18 -0
  80. data/spec/apps/dummy/config/boot.rb +2 -0
  81. data/spec/apps/dummy/config/environment.rb +2 -0
  82. data/spec/apps/dummy/config/environments/test.rb +38 -0
  83. data/spec/apps/dummy/config/initializers/cookies_serializer.rb +3 -0
  84. data/spec/apps/dummy/config/initializers/scimitar.rb +61 -0
  85. data/spec/apps/dummy/config/initializers/session_store.rb +3 -0
  86. data/spec/apps/dummy/config/routes.rb +45 -0
  87. data/spec/apps/dummy/db/migrate/20210304014602_create_mock_users.rb +24 -0
  88. data/spec/apps/dummy/db/migrate/20210308020313_create_mock_groups.rb +10 -0
  89. data/spec/apps/dummy/db/migrate/20210308044214_create_join_table_mock_groups_mock_users.rb +13 -0
  90. data/spec/apps/dummy/db/schema.rb +48 -0
  91. data/spec/controllers/scimitar/application_controller_spec.rb +296 -0
  92. data/spec/controllers/scimitar/resource_types_controller_spec.rb +94 -0
  93. data/spec/controllers/scimitar/resources_controller_spec.rb +247 -0
  94. data/spec/controllers/scimitar/schemas_controller_spec.rb +83 -0
  95. data/spec/controllers/scimitar/service_provider_configurations_controller_spec.rb +22 -0
  96. data/spec/models/scimitar/complex_types/address_spec.rb +18 -0
  97. data/spec/models/scimitar/complex_types/email_spec.rb +21 -0
  98. data/spec/models/scimitar/lists/count_spec.rb +147 -0
  99. data/spec/models/scimitar/lists/query_parser_spec.rb +830 -0
  100. data/spec/models/scimitar/resource_type_spec.rb +21 -0
  101. data/spec/models/scimitar/resources/base_spec.rb +485 -0
  102. data/spec/models/scimitar/resources/base_validation_spec.rb +86 -0
  103. data/spec/models/scimitar/resources/mixin_spec.rb +3562 -0
  104. data/spec/models/scimitar/resources/user_spec.rb +68 -0
  105. data/spec/models/scimitar/schema/attribute_spec.rb +99 -0
  106. data/spec/models/scimitar/schema/base_spec.rb +64 -0
  107. data/spec/models/scimitar/schema/group_spec.rb +87 -0
  108. data/spec/models/scimitar/schema/user_spec.rb +720 -0
  109. data/spec/requests/active_record_backed_resources_controller_spec.rb +1354 -0
  110. data/spec/requests/application_controller_spec.rb +61 -0
  111. data/spec/requests/controller_configuration_spec.rb +17 -0
  112. data/spec/requests/engine_spec.rb +45 -0
  113. data/spec/spec_helper.rb +101 -0
  114. data/spec/spec_helper_spec.rb +30 -0
  115. data/spec/support/hash_with_indifferent_case_insensitive_access_spec.rb +169 -0
  116. metadata +321 -0
@@ -0,0 +1,61 @@
1
+ # Some tests require the more flexible driver methods for 'get', 'post'
2
+ # etc. than available in RSpec controller tests.
3
+ #
4
+ # See also spec/controllers/scimitar/application_controller_spec.rb.
5
+ #
6
+ require 'spec_helper'
7
+
8
+ RSpec.describe Scimitar::ApplicationController do
9
+ before :each do
10
+ allow_any_instance_of(Scimitar::ApplicationController).to receive(:authenticated?).and_return(true)
11
+ end
12
+
13
+ context 'format handling' do
14
+ it 'renders "OK" if the request does not provide any Content-Type value' do
15
+ get '/CustomRequestVerifiers', params: { format: :html }
16
+
17
+ expect(response).to have_http_status(:ok)
18
+ parsed_body = JSON.parse(response.body)
19
+ expect(parsed_body['request']['is_scim' ]).to eql(true)
20
+ expect(parsed_body['request']['format' ]).to eql('application/scim+json')
21
+ expect(parsed_body['request']['content_type']).to eql('application/scim+json') # Filled in by ApplicationController#require_scim
22
+ end
23
+
24
+ it 'renders 400 if given bad JSON' do
25
+ post '/CustomRequestVerifiers', params: 'not-json-12345', headers: { 'CONTENT_TYPE' => 'application/scim+json' }
26
+
27
+ expect(response).to have_http_status(:bad_request)
28
+ expect(JSON.parse(response.body)['detail']).to start_with('Invalid JSON - ')
29
+ end
30
+
31
+ it 'translates Content-Type to Rails request format' do
32
+ get '/CustomRequestVerifiers', headers: { 'CONTENT_TYPE' => 'application/scim+json' }
33
+
34
+ expect(response).to have_http_status(:ok)
35
+ parsed_body = JSON.parse(response.body)
36
+ expect(parsed_body['request']['is_scim' ]).to eql(true)
37
+ expect(parsed_body['request']['format' ]).to eql('application/scim+json')
38
+ expect(parsed_body['request']['content_type']).to eql('application/scim+json')
39
+ end
40
+
41
+ it 'translates Content-Type with charset to Rails request format' do
42
+ get '/CustomRequestVerifiers', headers: { 'CONTENT_TYPE' => 'application/scim+json; charset=utf-8' }
43
+
44
+ expect(response).to have_http_status(:ok)
45
+ parsed_body = JSON.parse(response.body)
46
+ expect(parsed_body['request']['is_scim' ]).to eql(true)
47
+ expect(parsed_body['request']['format' ]).to eql('application/scim+json')
48
+ expect(parsed_body['request']['content_type']).to eql('application/scim+json; charset=utf-8')
49
+ end
50
+
51
+ it 'translates Rails request format to header' do
52
+ get '/CustomRequestVerifiers', params: { format: :scim }
53
+
54
+ expect(response).to have_http_status(:ok)
55
+ parsed_body = JSON.parse(response.body)
56
+ expect(parsed_body['request']['is_scim' ]).to eql(true)
57
+ expect(parsed_body['request']['format' ]).to eql('application/scim+json')
58
+ expect(parsed_body['request']['content_type']).to eql('application/scim+json')
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Controller configuration' do
4
+ before :each do
5
+ allow_any_instance_of(Scimitar::ApplicationController).to receive(:authenticated?).and_return(true)
6
+ end
7
+
8
+ context 'application_controller_mixin' do
9
+ it 'the test before-action declared in configuration gets called' do
10
+ expect_any_instance_of(MockUsersController).to receive(:test_hook)
11
+
12
+ get '/Users', params: { format: :scim }
13
+
14
+ expect(response).to be_ok
15
+ end
16
+ end # "context 'application_controller_mixin' do"
17
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Scimitar::Engine do
4
+ before :each do
5
+ allow_any_instance_of(Scimitar::ApplicationController).to receive(:authenticated?).and_return(true)
6
+ end
7
+
8
+ context 'parameter parser' do
9
+
10
+ # "params" given here as a String, expecting the engine's custom parser to
11
+ # decode it for us.
12
+ #
13
+ it 'decodes simple JSON', type: :model do
14
+ post '/Users.scim', params: '{"userName": "foo"}', headers: { 'CONTENT_TYPE' => 'application/scim+json' }
15
+
16
+ expect(response.status).to eql(201)
17
+ expect(JSON.parse(response.body)['userName']).to eql('foo')
18
+ end
19
+
20
+ it 'decodes nested JSON', type: :model do
21
+ post '/Users.scim', params: '{"userName": "foo", "name": {"givenName": "bar", "familyName": "baz"}}', headers: { 'CONTENT_TYPE' => 'application/scim+json' }
22
+
23
+ expect(response.status).to eql(201)
24
+ expect(JSON.parse(response.body)['userName']).to eql('foo')
25
+ expect(JSON.parse(response.body)['name']['givenName']).to eql('bar')
26
+ expect(JSON.parse(response.body)['name']['familyName']).to eql('baz')
27
+ end
28
+
29
+ it 'is case insensitive at the top level', type: :model do
30
+ post '/Users.scim', params: '{"USERNAME": "foo"}', headers: { 'CONTENT_TYPE' => 'application/scim+json' }
31
+
32
+ expect(response.status).to eql(201)
33
+ expect(JSON.parse(response.body)['userName']).to eql('foo')
34
+ end
35
+
36
+ it 'is case insensitive in nested levels', type: :model do
37
+ post '/Users.scim', params: '{"USERNAME": "foo", "NAME": {"GIVENNAME": "bar", "FAMILYNAME": "baz"}}', headers: { 'CONTENT_TYPE' => 'application/scim+json' }
38
+
39
+ expect(response.status).to eql(201)
40
+ expect(JSON.parse(response.body)['userName']).to eql('foo')
41
+ expect(JSON.parse(response.body)['name']['givenName']).to eql('bar')
42
+ expect(JSON.parse(response.body)['name']['familyName']).to eql('baz')
43
+ end
44
+ end # "context 'parameter parser' do"
45
+ end
@@ -0,0 +1,101 @@
1
+ # ============================================================================
2
+ # PREAMBLE
3
+ # ============================================================================
4
+
5
+ # Get code coverage reports:
6
+ #
7
+ # https://github.com/colszowka/simplecov#getting-started
8
+ #
9
+ # "Load and launch SimpleCov at the very top of your test/test_helper.rb (or
10
+ # spec_helper.rb [...])"
11
+ #
12
+ require 'simplecov'
13
+ SimpleCov.start 'rails'
14
+
15
+ # Rails stuff is related to the self-test applications in 'spec/apps'.
16
+ #
17
+ ENV['RAILS_ENV'] ||= 'test'
18
+ require File.expand_path('../apps/dummy/config/environment', __FILE__)
19
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
20
+
21
+ require 'rspec/rails'
22
+ require 'byebug'
23
+ require 'scimitar'
24
+
25
+ # ============================================================================
26
+ # MAIN RSPEC CONFIGURATION
27
+ # ============================================================================
28
+
29
+ RSpec.configure do | config |
30
+ config.disable_monkey_patching!
31
+ config.infer_spec_type_from_file_location!
32
+ config.filter_rails_from_backtrace!
33
+ config.raise_errors_for_deprecations!
34
+
35
+ config.color = true
36
+ config.tty = true
37
+ config.order = :random
38
+ config.fixture_paths = ["#{::Rails.root}/spec/fixtures"]
39
+ config.use_transactional_fixtures = true
40
+
41
+ Kernel.srand config.seed
42
+
43
+ config.around :each do | example |
44
+ original_engine_configuration = Scimitar.instance_variable_get('@engine_configuration')
45
+ example.run()
46
+ ensure
47
+ Scimitar.instance_variable_set('@engine_configuration', original_engine_configuration)
48
+ end
49
+ end
50
+
51
+ # ============================================================================
52
+ # MISCELLANEOUS UTILITIES
53
+ # ============================================================================
54
+
55
+ # Capture stdout from running a given block.
56
+ #
57
+ def spec_helper_capture_stdout( &block )
58
+ result = ''
59
+
60
+ begin
61
+ old_stdout = $stdout
62
+ $stdout = StringIO.new
63
+
64
+ yield
65
+
66
+ result = $stdout.string
67
+
68
+ ensure
69
+ $stdout = old_stdout
70
+
71
+ end
72
+
73
+ return result
74
+ end
75
+
76
+ # Recursively transform the keys of any given Hash or any Hashes in a given
77
+ # Array into uppercase form, retaining Symbol or String keys. Returns the
78
+ # transformed duplicate structure.
79
+ #
80
+ # Only Hashes or Hash entries within an Array are converted. Other data is left
81
+ # alone. The original input item is not modified.
82
+ #
83
+ # IMPORTANT: HashWithIndifferentAccess or similar subclasses are not supported.
84
+ #
85
+ # +item+:: Hash or Array that might contain some Hashes.
86
+ #
87
+ def spec_helper_hupcase(item)
88
+ if item.is_a?(Hash)
89
+ rehash = item.transform_keys(&:upcase)
90
+ rehash.each do | key, value |
91
+ rehash[key] = spec_helper_hupcase(value)
92
+ end
93
+ rehash
94
+ elsif item.is_a?(Array)
95
+ item.map do | array_entry |
96
+ spec_helper_hupcase(array_entry)
97
+ end
98
+ else
99
+ item
100
+ end
101
+ end
@@ -0,0 +1,30 @@
1
+ # Self-test. Sometimes tests call into utility methods in spec_helper.rb;
2
+ # if those aren't doing what they should, then the tests might give false
3
+ # positive passes.
4
+ #
5
+ require 'spec_helper'
6
+
7
+ RSpec.describe 'spec_helper.rb self-test' do
8
+ context '#spec_helper_hupcase' do
9
+ it 'converts a flat Hash, preserving data type of keys' do
10
+ input = {:one => 1, 'two' => 2}
11
+ output = spec_helper_hupcase(input)
12
+
13
+ expect(output).to eql({:ONE => 1, 'TWO' => 2})
14
+ end
15
+
16
+ it 'converts a nested Hash' do
17
+ input = {:one => 1, 'two' => {:tHrEe => {'fOuR' => 4}}}
18
+ output = spec_helper_hupcase(input)
19
+
20
+ expect(output).to eql({:ONE => 1, 'TWO' => {:THREE => {'FOUR' => 4}}})
21
+ end
22
+
23
+ it 'converts an Array with Hashes' do
24
+ input = {:one => 1, 'two' => [true, 42, {:tHrEe => {'fOuR' => 4}}]}
25
+ output = spec_helper_hupcase(input)
26
+
27
+ expect(output).to eql({:ONE => 1, 'TWO' => [true, 42, {:THREE => {'FOUR' => 4}}]})
28
+ end
29
+ end # "context '#spec_helper_hupcase' do"
30
+ end
@@ -0,0 +1,169 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Scimitar::Support::HashWithIndifferentCaseInsensitiveAccess do
4
+ shared_examples 'an indifferent access, case insensitive Hash' do
5
+ context 'where keys set as strings' do
6
+ it 'can be retrieved via any case' do
7
+ subject()['foo'] = 1
8
+
9
+ expect(subject()['FOO']).to eql(1)
10
+ expect(subject()[:FoO ]).to eql(1)
11
+ expect(subject()['bar']).to be_nil
12
+ end
13
+
14
+ it 'can be checked for via any case' do
15
+ subject()['foo'] = 1
16
+
17
+ expect(subject()).to have_key('FOO')
18
+ expect(subject()).to have_key(:FoO )
19
+ expect(subject()).to_not have_key('bar')
20
+ end
21
+ end # "context 'where keys set as strings' do"
22
+
23
+ context 'where keys set as symbols' do
24
+ it 'retrieves via any case' do
25
+ subject()[:foo] = 1
26
+
27
+ expect(subject()['FOO']).to eql(1)
28
+ expect(subject()[:FoO ]).to eql(1)
29
+ expect(subject()['bar']).to be_nil
30
+ end
31
+
32
+ it 'enquires via any case' do
33
+ subject()[:foo] = 1
34
+
35
+ expect(subject()).to have_key('FOO')
36
+ expect(subject()).to have_key(:FoO )
37
+ expect(subject()).to_not have_key('bar')
38
+ end
39
+ end # "context 'where keys set as symbols' do"
40
+
41
+ context 'access and merging' do
42
+ before :each do
43
+ @original_subject = subject().to_h().dup()
44
+ end
45
+
46
+ it 'returns keys as Strings' do
47
+ subject()[:foo] = 1
48
+ subject()[:BAR] = 2
49
+
50
+ expect(subject().keys).to match_array(@original_subject.keys + ['foo', 'BAR'])
51
+ end
52
+
53
+ it 'retains original case of keys' do
54
+ subject()[:foo ] = 1
55
+ subject()['FoO'] = 40 # (first-time-set case preservation test in passing)
56
+ subject()[:BAR ] = 2
57
+ subject()['Baz'] = 3
58
+
59
+ expectation = @original_subject.merge({
60
+ 'foo' => 40,
61
+ 'BAR' => 2,
62
+ 'Baz' => 3
63
+ })
64
+
65
+ expect(subject()).to eql(expectation)
66
+ end
67
+
68
+ it '#merge does not mutate the receiver and retains case of first-set keys' do
69
+ subject()[:foo] = 1
70
+ subject()[:BAR] = 2
71
+
72
+ pre_merge_subject = subject().dup()
73
+
74
+ result = subject().merge({:FOO => { 'onE' => 40 }, :Baz => 3})
75
+ expectation = @original_subject.merge({
76
+ 'foo' => { 'onE' => 40 },
77
+ 'BAR' => 2,
78
+ 'Baz' => 3
79
+ })
80
+
81
+ expect(subject()).to eql(pre_merge_subject)
82
+ expect(result).to eql(expectation)
83
+ end
84
+
85
+ it '#merge! mutates the receiver retains case of first-set keys' do
86
+ subject()[:foo] = 1
87
+ subject()[:BAR] = 2
88
+
89
+ subject().merge!({:FOO => { 'onE' => 40 }, :Baz => 3})
90
+
91
+ expectation = @original_subject.merge({
92
+ 'foo' => { 'onE' => 40 },
93
+ 'BAR' => 2,
94
+ 'Baz' => 3
95
+ })
96
+
97
+ expect(subject()).to eql(expectation)
98
+ end
99
+
100
+ it '#deep_merge does not mutate the receiver and retains nested key cases' do
101
+ subject()[:foo] = { :one => 10 }
102
+ subject()[:BAR] = 2
103
+
104
+ pre_merge_subject = subject().dup()
105
+
106
+ result = subject().deep_merge({:FOO => { 'ONE' => 40, :TWO => 20 }, :Baz => 3})
107
+ expectation = @original_subject.merge({
108
+ 'foo' => { 'one' => 40, 'TWO' => 20 },
109
+ 'BAR' => 2,
110
+ 'Baz' => 3
111
+ })
112
+
113
+ expect(subject()).to eql(pre_merge_subject)
114
+ expect(result).to eql(expectation)
115
+ end
116
+
117
+ it '#deep_merge! mutates the receiver and retains nested key cases' do
118
+ subject()[:foo] = { :one => 10 }
119
+ subject()[:BAR] = 2
120
+
121
+ subject().deep_merge!({:FOO => { 'ONE' => 40, :TWO => 20 }, :Baz => 3})
122
+
123
+ expectation = @original_subject.merge({
124
+ 'foo' => { 'one' => 40, 'TWO' => 20 },
125
+ 'BAR' => 2,
126
+ 'Baz' => 3
127
+ })
128
+
129
+ expect(subject()).to eql(expectation)
130
+ end
131
+
132
+ it 'retains indifferent behaviour after duplication' do
133
+ subject()[:foo] = { 'onE' => 40 }
134
+ subject()[:BAR] = 2
135
+
136
+ duplicate = subject().dup()
137
+ duplicate.merge!({ 'FOO' => true, 'baz' => 3 })
138
+
139
+ expectation = @original_subject.merge({
140
+ 'foo' => true,
141
+ 'BAR' => 2,
142
+ 'baz' => 3
143
+ })
144
+
145
+ expect(duplicate.to_h).to eql(expectation.to_h)
146
+ end
147
+ end # "context 'access and merging' do"
148
+ end # "shared_examples 'an indifferent access, case insensitive Hash' do"
149
+
150
+ context 'when created directly' do
151
+ subject do
152
+ described_class.new()
153
+ end
154
+
155
+ it_behaves_like 'an indifferent access, case insensitive Hash'
156
+ end # "context 'when created directly' do"
157
+
158
+ context 'when created through conversion' do
159
+ subject do
160
+ { 'test' => 2 }.with_indifferent_access.with_indifferent_case_insensitive_access()
161
+ end
162
+
163
+ it 'includes the original data' do
164
+ expect(subject()[:TEST]).to eql(2)
165
+ end
166
+
167
+ it_behaves_like 'an indifferent access, case insensitive Hash'
168
+ end # "context 'converting hashes' do"
169
+ end