Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to run tests as a developer... #549

Closed
timdiggins opened this issue Oct 19, 2021 · 5 comments · Fixed by #550
Closed

trying to run tests as a developer... #549

timdiggins opened this issue Oct 19, 2021 · 5 comments · Fixed by #550

Comments

@timdiggins
Copy link
Contributor

I'm trying to run the tests as a developer (working on #538 )

I've set up a Demo company and custom connection and set export XERO_CLIENT_ID= to given id and created as secret and set it locally as export XERO_CLIENT_SECRET=. However it's not that obvious how or what to set XERO_ACCESS_TOKEN and XERO_TENANT_ID to. As a result some of the non-unit tests are failing. But that's noise. Everything else passes when I do bundle exec rake test

I'm trying to run one file but when I try bundle exec rake test TEST=test/unit/record/base_test.rb I get lots of these kind of tracebacks:

Error: test: saving invalid record should return false saving with #save. (RecordBaseTest): NoMethodError: undefined method `stubs' for #<Xeroizer::Record::Contact :name: "Test Contact Name ABC">
/Users/xxx/workspaces/xxx/xeroizer/test/unit/record/base_test.rb:121:in `block (3 levels) in <class:RecordBaseTest>'
/Users/xxx/.rvm/gems/ruby-2.7.3@xeroizer/gems/shoulda-context-1.2.2/lib/shoulda/context/context.rb:438:in `instance_exec'
/Users/xxx/.rvm/gems/ruby-2.7.3@xeroizer/gems/shoulda-context-1.2.2/lib/shoulda/context/context.rb:438:in `block in run_current_setup_blocks'
/Users/xxx/.rvm/gems/ruby-2.7.3@xeroizer/gems/shoulda-context-1.2.2/lib/shoulda/context/context.rb:436:in `each'
/Users/xxx/.rvm/gems/ruby-2.7.3@xeroizer/gems/shoulda-context-1.2.2/lib/shoulda/context/context.rb:436:in `run_current_setup_blocks'
/Users/xxx/workspaces/xxx/xeroizer/test/unit/record/base_test.rb:144:in `block in create_test_from_should_hash'

I don't often use minitest/shoulda but somether here is not set up correctly when running a single test.

Any ideas?

@timdiggins
Copy link
Contributor Author

Actually - I've worked that one out - there was a line in tax_rate_test.rb which really needs to be in unit_test_helper. See PR

@rjaus
Copy link
Collaborator

rjaus commented Oct 19, 2021

Personally, I use Insomnia Rest client to run the authorisation, then I export my access token & tenantId into my local environment
export XERO_ACCESS_TOKEN=asdfsadfsafsdf
export XERO_TENANT_ID=asdfasdf

I guess this could be resolved by writing some setup tests which throw open a browser to conduct the oauth flow, to save the token & tenantId in the test environment.

The demo company needs to be manually reset, which is an additional complication for running automated tests.

@timdiggins
Copy link
Contributor Author

Thanks Riley. What do you think about adding vcr to the test setup and making the setup and (re)generation of the vcr cassettes a manual occasional process for developers?

However maybe given that xero are behind https://github.com/XeroAPI/xero-ruby maybe it's more sensible for me to focus efforts on switching to that gem rather than pouring effort into this one.

@rjaus
Copy link
Collaborator

rjaus commented Oct 21, 2021

Hey @timdiggins, if you are at an early enough stage that switching is possible, then moving to xero-ruby would make sense. Xero will definitely be focusing its efforts on that SDK. Xeroizer has always been a community led effort.

But where ever you choose to throw PRs, we definitely appreciate them! 👍

@timdiggins
Copy link
Contributor Author

@rjaus Thanks, helpful. Could you merge #550? It's a good and (I think) uncontroversial fix for a misplaced require which is not related to #551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants