Skip to content

Commit

Permalink
operation -> action in BGSClientSpecHelpers for naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
nihil2501 committed Apr 26, 2024
1 parent 7dc9ae1 commit 0c82c67
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/claims_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ssh -L 4447:localhost:4447 {{aws-url}}
ssh -L 4431:localhost:4431 {{aws-url}}

## Testing
### Unit testing BGS service operation wrappers
### Unit testing BGS service action wrappers
If using cassettes, make sure to only make or use ones under [spec/support/vcr_cassettes/claims_api](spec/support/vcr_cassettes/claims_api)
Check out documentation in comments for the spec helper `BGSClientSpecHelpers#use_bgs_cassette`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'veteran_representative_service',
operation: 'create_veteran_representative'
action: 'create_veteran_representative'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'veteran_representative_service',
operation: 'read_all_veteran_representatives'
action: 'read_all_veteran_representatives'
},
run_at: '2024-04-17T23:10:31+00:00'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'manage_representative_service',
operation: 'read_poa_request'
action: 'read_poa_request'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'manage_representative_service',
operation: 'update_poa_request'
action: 'update_poa_request'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'vnp_atchms_service',
operation: 'vnp_atchms_create'
action: 'vnp_atchms_create'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'vnp_person_service',
operation: 'vnp_person_create'
action: 'vnp_person_create'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
metadata = {
bgs: {
service: 'vnp_ptcpnt_addrs_service',
operation: 'vnp_ptcpnt_addrs_create'
action: 'vnp_ptcpnt_addrs_create'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
production: false,
bgs: {
service: 'manage_representative_service',
operation: 'read_poa_request'
action: 'read_poa_request'
}
}

Expand Down
14 changes: 7 additions & 7 deletions modules/claims_api/spec/support/bgs_client_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ module BGSClientSpecHelpers
}.freeze

# This convenience method affords a handful of quality of life improvements
# for developing BGS service operation wrappers. It makes development a less
# for developing BGS service action wrappers. It makes development a less
# manual process. It also turns VCR cassettes into a human readable resource
# that documents the behavior of BGS.
#
# In order to take advantage of this method, you will need to have supplied,
# to your example or example group, metadata of this form:
# `{ bgs: { service: "service", operation: "operation" } }`.
# `{ bgs: { service: "service", action: "action" } }`.
#
# Then, HTTP interactions that occur within the block supplied to this method
# will be captured by VCR cassettes that have the following convenient
# properties:
# - They will be nicely organized at `claims_api/bgs/:service/:operation/:name`
# - They will be nicely organized at `claims_api/bgs/:service/:action/:name`
# - Cassette matching will be done on canonicalized XML bodies, so
# reformatting cassettes for human readability won't defeat matching
def use_bgs_cassette(name, &)
metadata = RSpec.current_example.metadata[:bgs].to_h
service, operation = metadata.values_at(:service, :operation)
service, action = metadata.values_at(:service, :action)

if service.blank? || operation.blank?
if service.blank? || action.blank?
raise ArgumentError, <<~HEREDOC
Must provide spec metadata of the form:
`{ bgs: { service: "service", operation: "operation" } }'
`{ bgs: { service: "service", action: "action" } }'
HEREDOC
end

name = File.join('claims_api/bgs', service, operation, name)
name = File.join('claims_api/bgs', service, action, name)
VCR.use_cassette(name, VCR_OPTIONS, &)
end
end
Expand Down

0 comments on commit 0c82c67

Please sign in to comment.