hoodoo 2.5.1 → 2.6.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.
@@ -101,6 +101,13 @@ describe Hoodoo::ActiveRecord::Writer do
101
101
  expect( result ).to eq( :success )
102
102
  expect_no_error( record )
103
103
  end
104
+
105
+ it 'via alias' do
106
+ record = klass.new( unique_attributes() )
107
+ result = record.update_in( @context )
108
+ expect( result ).to eq( :success )
109
+ expect_no_error( record )
110
+ end
104
111
  end
105
112
 
106
113
  context 'with AR validations present' do
@@ -140,6 +147,13 @@ describe Hoodoo::ActiveRecord::Writer do
140
147
  expect( result ).to eq( :failure )
141
148
  expect_correct_error( record, error_reference )
142
149
  end
150
+
151
+ it 'via alias' do
152
+ record = klass.new( record_to_copy().attributes() )
153
+ result = record.update_in( @context )
154
+ expect( result ).to eq( :failure )
155
+ expect_correct_error( record, error_reference )
156
+ end
143
157
  end
144
158
 
145
159
  context 'with AR validations present' do
@@ -240,6 +240,8 @@ describe Hoodoo::Client do
240
240
  end
241
241
 
242
242
  before :all do
243
+ $alternating_test = ( rand( 2 ) == 0 ) # 50% chance of starting true / false
244
+
243
245
  @old_test_session = Hoodoo::Services::Middleware.test_session()
244
246
  @port = spec_helper_start_svc_app_in_thread_for( RSpecClientTestService )
245
247
  @https_port = spec_helper_start_svc_app_in_thread_for( RSpecClientTestService, true )
@@ -293,13 +295,20 @@ describe Hoodoo::Client do
293
295
  endpoint_opts[ :assume_identity_of ] = @assume_identity_of unless @assume_identity_of.nil?
294
296
  endpoint_opts[ :deja_vu ] = @deja_vu if @deja_vu == true
295
297
 
296
- if rand( 2 ) == 0
298
+ # Alternate between checks of alternative locales and use of the
299
+ # native #resource interface versus the #endpoint alias.
300
+ #
301
+ if $alternating_test == true
297
302
  override_locale = SecureRandom.urlsafe_base64( 2 )
298
303
  endpoint_opts[ :locale ] = override_locale
299
304
  @expected_locale = override_locale.downcase
305
+
306
+ @endpoint = @client.endpoint( :RSpecClientTestTarget, 1, endpoint_opts )
307
+ else
308
+ @endpoint = @client.resource( :RSpecClientTestTarget, 1, endpoint_opts )
300
309
  end
301
310
 
302
- @endpoint = @client.resource( :RSpecClientTestTarget, 1, endpoint_opts )
311
+ $alternating_test = ! $alternating_test
303
312
  end
304
313
 
305
314
  # Automatic expectations based on HEADER_TO_PROPERTY are fine here as they
@@ -19,7 +19,7 @@ describe Hoodoo::Services::Context do
19
19
  comprised_of RSpecTestContextInterface
20
20
  end
21
21
 
22
- it 'should initialise correctly' do
22
+ it 'initialises correctly' do
23
23
  ses = Hoodoo::Services::Session.new
24
24
  req = Hoodoo::Services::Request.new
25
25
  res = Hoodoo::Services::Response.new( Hoodoo::UUID.generate() )
@@ -34,19 +34,33 @@ describe Hoodoo::Services::Context do
34
34
  expect(con.owning_interaction).to eq(int)
35
35
  end
36
36
 
37
- it 'should report endpoints' do
38
- ses = Hoodoo::Services::Session.new
39
- req = Hoodoo::Services::Request.new
40
- res = Hoodoo::Services::Response.new( Hoodoo::UUID.generate() )
41
- mid = Hoodoo::Services::Middleware.new( RSpecTestContext.new )
42
- int = Hoodoo::Services::Middleware::Interaction.new( {}, mid )
37
+ context 'reports endpoints' do
38
+ before :each do
39
+ ses = Hoodoo::Services::Session.new
40
+ req = Hoodoo::Services::Request.new
41
+ res = Hoodoo::Services::Response.new( Hoodoo::UUID.generate() )
42
+ mid = Hoodoo::Services::Middleware.new( RSpecTestContext.new )
43
+ int = Hoodoo::Services::Middleware::Interaction.new( {}, mid )
43
44
 
44
- con = Hoodoo::Services::Context.new( ses, req, res, int )
45
+ @con = Hoodoo::Services::Context.new( ses, req, res, int )
46
+ end
47
+
48
+ shared_examples 'an endpoint' do | endpoint_method |
49
+ it 'with the expected properties' do
50
+ expect(@con.send(endpoint_method, :RSpecTestResource)).to be_a( Hoodoo::Services::Middleware::InterResourceLocal )
51
+ expect(@con.send(endpoint_method, :RSpecTestResource).instance_variable_get( '@discovery_result' ) ).to be_a( Hoodoo::Services::Discovery::ForLocal )
52
+ expect(@con.send(endpoint_method, :RSpecTestResource).instance_variable_get( '@discovery_result' ) .interface_class).to eq( RSpecTestContextInterface )
53
+ expect(@con.send(endpoint_method, :AnotherResource)).to be_a( Hoodoo::Services::Middleware::InterResourceRemote )
54
+ expect(@con.send(endpoint_method, :AnotherResource).instance_variable_get( '@discovery_result' ) ).to be_a( Hoodoo::Services::Discovery::ForRemote )
55
+ end
56
+ end
45
57
 
46
- expect(con.resource(:RSpecTestResource)).to be_a( Hoodoo::Services::Middleware::InterResourceLocal )
47
- expect(con.resource(:RSpecTestResource).instance_variable_get( '@discovery_result' ) ).to be_a( Hoodoo::Services::Discovery::ForLocal )
48
- expect(con.resource(:RSpecTestResource).instance_variable_get( '@discovery_result' ) .interface_class).to eq( RSpecTestContextInterface )
49
- expect(con.resource(:AnotherResource)).to be_a( Hoodoo::Services::Middleware::InterResourceRemote )
50
- expect(con.resource(:AnotherResource).instance_variable_get( '@discovery_result' ) ).to be_a( Hoodoo::Services::Discovery::ForRemote )
58
+ context 'via native "#resource" and' do
59
+ it_behaves_like 'an endpoint', :resource
60
+ end
61
+
62
+ context 'via alias "#endpoint" and' do
63
+ it_behaves_like 'an endpoint', :endpoint
64
+ end
51
65
  end
52
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoodoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loyalty New Zealand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dalli
@@ -297,6 +297,7 @@ files:
297
297
  - lib/hoodoo/active/active_record/manually_dated.rb
298
298
  - lib/hoodoo/active/active_record/search_helper.rb
299
299
  - lib/hoodoo/active/active_record/secure.rb
300
+ - lib/hoodoo/active/active_record/security_helper.rb
300
301
  - lib/hoodoo/active/active_record/support.rb
301
302
  - lib/hoodoo/active/active_record/translated.rb
302
303
  - lib/hoodoo/active/active_record/uuid.rb
@@ -420,6 +421,7 @@ files:
420
421
  - spec/active/active_record/manually_dated_spec.rb
421
422
  - spec/active/active_record/search_helper_spec.rb
422
423
  - spec/active/active_record/secure_spec.rb
424
+ - spec/active/active_record/security_helper_spec.rb
423
425
  - spec/active/active_record/support_spec.rb
424
426
  - spec/active/active_record/translated_spec.rb
425
427
  - spec/active/active_record/uuid_spec.rb
@@ -554,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
554
556
  version: '0'
555
557
  requirements: []
556
558
  rubyforge_project:
557
- rubygems_version: 2.7.6
559
+ rubygems_version: 2.6.14
558
560
  signing_key:
559
561
  specification_version: 4
560
562
  summary: Opinionated APIs
@@ -567,6 +569,7 @@ test_files:
567
569
  - spec/active/active_record/manually_dated_spec.rb
568
570
  - spec/active/active_record/search_helper_spec.rb
569
571
  - spec/active/active_record/secure_spec.rb
572
+ - spec/active/active_record/security_helper_spec.rb
570
573
  - spec/active/active_record/support_spec.rb
571
574
  - spec/active/active_record/translated_spec.rb
572
575
  - spec/active/active_record/uuid_spec.rb