-
Notifications
You must be signed in to change notification settings - Fork 0
Running Specs and Linting
To ensure correctness Asimov
includes a comprehensive test suite that is intended to test both "happy path" and error behavior.
This gem aims for ~100% spec coverage, so please make sure to add specs for any new functionality.
The Asimov
specs can be run in two modes:
- Local - No OpenAI API calls will be made
- Live - Calls the OpenAI API and processes the responses as part of the run
To run specs in local mode, do the following:
- Run
bin/setup
(you will only need to do this once) - Run
bundle exec rake
This mode for specs uses VCR
cassettes to replay previous responses from the OpenAI API.
When submitting a PR, please run specs in local mode on your machine or on your fork to ensure that they run green.
To run specs in local mode, do the following:
- Run
bin/setup
(you will only need to do this once) - Set
RUN_LIVE=true
in the environment - Set
OPENAI_API_KEY
to a valid OpenAI API key. - Run
bundle exec rake
This mode for specs will make live calls to the OpenAI API. The cost for these calls should be a few cents per full spec run.
You can do this all in one call by running:
RUN_LIVE=true OPENAI_API_KEY=<Your API key here> bundle exec rake
Only feature specs (those in the spec/features
directory) will make OpenAI API calls. Rather than running the full suite, you can run individual feature spec files or specs by using bundle exec rspec ...
with the appropriate argument.
Running feature specs in this mode will refresh existing cassettes.
To help ensure a consistent style across the gem, Asimov
includes a linter in its CI pipeline. Use of a linter not only enforces consistent styling, but also helps ensure against certain classes of error.
Asimov
uses Rubocop
for linting, and by default uses the default configuration for all Cops. New Cops are automatically included.
To run Rubocop
, do the following:
- Run
bin/setup
(you will only need to do this once) - Run
bundle update rubocop
to ensure you are bundling with the latestRubocop
- Run
bundle exec rubocop
When submitting a PR, please run Rubocop
beforehand to make sure there are no outstanding lints that need to be addressed. If you'd like to make a change to Rubocop
behavior - either by updating the .rubocop.yml
or by adding an inline disable/enable
, please note that in the PR description.