The modern Ruby QuickBooks client Part 2
"Real world" fixtures
The qbo_api gem's specs were built against an official QuickBooks sandbox and then recorded using the VCR gem. Therefore, you have a fantastically quick way to get started with your integration project in that you can see "real world" QBO API transaction without your own sandbox or even a network connection. Allow me to demonstrate.
- Clone the
qbo_apigem, switch into the new directory, andbundle - Create a .env file If you are just running the specs then at minimum your .env needs to look like the following:
- Now you can run the specs by doing a
bundle exec rspec spec/ - Let's open up the
spec/create_update_delete_spec.rb - Then go to the first spec where abouts the VCR cassette is being recorded.
- The
credsmethod is defined in thespec/spec_helper.rb - Before the initialize set
QboApi.log = trueand run the individual spec. - Now let's mess around with the response by outputing the invoice's customer name
- Next, open up the
spec/error_spec.rband goto the spec titled "handles a validation error".
$ git clone git://github.com/minimul/qbo_api && cd qbo_api $ bundle
export QBO_API_CONSUMER_KEY= export QBO_API_CONSUMER_SECRET= export QBO_API_ACCESS_TOKEN= export QBO_API_ACCESS_TOKEN_SECRET= export QBO_API_COMPANY_ID=12345
This section is at the 2:48 mark.
be is a bash alias for bundle exec.
.env file is loaded by the
Dotenv gem.
Minimul says —
If you want to see an example of an advanced VCR custom matcher keep
reading the spec/spec_helper.rb file. The purpose of the
matcher is to make VCR more lenient so that any QuickBooks sandbox can be used.
This section is at the 5:29 mark.
qbo_api initialization and many other methods use keyword arguments, which is the primary reason for the Ruby 2.2.2
requirement.
log feature to view the HTTP transaction to QBO API.
p response['CustomerRef']['name'] and then comment out the QboApi.log = true to isolate the output to only the customer name.
This section is at the 7:44 mark.
Conclusion
When getting started with a QuickBooks integration project using the qbo_api gem leverage the "real world" recorded specs to help you get started quickly.
- Pushed on 01/23/2016 by Christian
- QuickBooks Integration Consulting
