| name | testing |
|---|---|
| description | Use when writing or fixing RSpec examples, WebMock stubs, JSON fixtures, SimpleCov, or env-based test helpers. |
- Adding specs under
spec/ - Changing CDN hosts, paths, or headers used in
Contentstack::API - Updating global
WebMockstubs inspec/spec_helper.rb - Interpreting SimpleCov output under
coverage/
- Run
bundle exec rspecfrom the repo root. spec/spec_helper.rbrequires WebMock/RSpec, disables real network (WebMock.disable_net_connect!(allow_localhost: true)), starts SimpleCov, and requirescontentstack.
- Default stubs live in
config.before(:each)inspec/spec_helper.rbfor hosts such ascdn.contentstack.io,eu-cdn.contentstack.com,custom-cdn.contentstack.com, andpreview.contentstack.io. - When adding endpoints or hosts, add matching
stub_requestentries and JSON fixtures underspec/fixtures/(reuse shape of real CDA responses where possible).
- Store static JSON under
spec/fixtures/*.json; load withFile.readrelative to__dir__orFile.dirname(__FILE__)as existing specs do.
create_clientandcreate_preview_clientinspec_helperbuild clients usingENV['API_KEY'],ENV['DELIVERY_TOKEN'],ENV['ENVIRONMENT']— tests should not rely on real credentials; stubs supply responses.
- SimpleCov runs on every
rspecinvocation; reviewcoverage/index.htmlafter substantivelib/changes.