Go back to the main page

The modern Ruby QuickBooks client: Part 3 - Gem Contributing

 

Record your own QBO sandbox transactions in a PR

You would like to enhance or fix something in the qbo_api gem but aren't too sure about the "VCR-recorded-sandbox-transaction" part of the specs. Don't you worry a bit about that. Frankly, this "VCR-recorded-sandbox-transaction" thing will actually make it easier for you to contribute and not the other way around. Creating fictional API fixtures is the harder and more error-prone approach.

  1. Fork the qbo_api gem
  2. Clone your fork, switch into the new directory, and bundle
  3.   $ git clone git://github.com/[your fork]/qbo_api && cd qbo_api
      $ bundle
    
  4. Make a new branch for your PR e.g. git checkout -b cust-ref-name
  5. Create a .env file and fill in all the values
    • Please see part 1, which will fully explain how to get all the values you need to properly fill in the .env file.
    This section is at the 2:22 mark.
  6. Next, run the specs bundle exec rspec spec/.
  7. Let's make sure the specs are green before we move on.
  8. Open the spec spec/create_update_delete_spec.rb
  9. Add a name attribute to the CustomerRef
  10. Here we are modifying an existing spec that creates an invoice. Its transaction has been recorded by VCR.
  11. Change the record setting to "all". record: :all and rerun
  12. We are rerunning the specs with a new payload. With the record: :all setting enabled the spec will test against your sandbox with VCR recording the transaction.
  13. Run the git status to see which files have been modified.
  14. Notice that the VCR recorded file spec/vcr/qbo_api/create/invoice.yml has been updated with the new recording.
  15. Change the record: :all back to record: :none.
  16. Commit the changes: git commit -a -m "Add CustomerRef:name information when create a new invoice"
  17. Then push the branch and submit the pull request.

Conclusion

Contributing to the qbo_api gem is a cinch. The fact that the gem utilizes VCR-recorded transactions against real QuickBooks sandboxes makes it a great choice. That said, don't be intimated at all by VCR; follow this tutorial and you will easily be able to contribute in making the gem even better.