A rough and ready debugging tool to help refactoring / moving logic from one application to another.
None required, this is a simple repository ready to be used.
- paste the log content of your legacy application in logs/a
- paste the log content of your new application in logs/b
bundle exec ruby log_parser.rb a
---
insert_products:
provider_id: '173'
quantity: '7'
reference: HJIK4
---
update_providers:
provider_id: '15935967'
status: live
bundle exec ruby log_parser.rb a hashes
{"provider_id"=>"173", "quantity"=>"7", "reference"=>"HJIK4"}
{"provider_id"=>"15935967", "status"=>"live"}
- create a yaml file per resource created in the database
- add those the yaml files under the relevant namespace, e.g
fixtures/a
for resources created by application a
- add as many context as resouces created
- make use of rpsec and its context mechanism to easily isolate potential discrepancies between one resouce created by application a VS application b.
bundle exec rspec spec/resources_spec.rb -e 'the name of my context describing a resource'
# e.g
bundle exec rspec spec/resources_spec.rb -e 'products'
Running the spec/resources_spec.rb
you will be presented with the following failure.
1) resources product generate the same attributes
Failure/Error: expect(application_b_object).to eq application_a_object
expected: {"provider_id"=>"173", "quantity"=>"7", "reference"=>"HJIK4"}
got: {"provider_id"=>"173", "quantity"=>"0"}
This illustrates that application b is not currently matching all actions performed by application a.
- quantity has not been set correctly on product
- the reference field has not been processed at all while using application b
Bug reports are welcome on GitHub at https://github.com/joe-at-github/a_b_refactoring.