You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Modernize test infrastructure and update to Ruby 3.4.1
- Reorganize tests: move integration tests to spec/requests/api/v1/
- Convert swagger specs to documentation-only
- Add health check endpoint for monitoring
- Update Ruby version from 3.3.0 to 3.4.1
- Enhance CI workflow with validation and swagger generation
- Add dev.env support for local development
- Update README with troubleshooting and test documentation
- Modernize dependabot configuration
- Add .tool-versions for asdf compatibility
- Include Ruby on Rails installation guide
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
@@ -15,7 +15,7 @@ To run this prebuilt project, you will need:
15
15
16
16
-[Couchbase Capella cluster](https://www.couchbase.com/products/capella/) with [travel-sample bucket](https://docs.couchbase.com/ruby-sdk/current/ref/travel-app-data-model.html) loaded.
17
17
- To run this tutorial using a [self-managed Couchbase cluster](https://docs.couchbase.com/capella/current/getting-started/self-managed-cluster.html), please refer to the appendix.
18
-
-[Ruby 3.3.0](https://www.ruby-lang.org/en/documentation/installation/) is installed on the local machine.
18
+
-[Ruby 3.4.1](https://www.ruby-lang.org/en/documentation/installation/) is installed on the local machine.
19
19
- Basic knowledge of [Ruby](https://www.ruby-lang.org/en/documentation/), [Ruby on Rails](https://rubyonrails.org/), and [RSpec](https://rspec.info/).
20
20
21
21
## Loading Travel Sample Bucket
@@ -48,7 +48,27 @@ To learn more about connecting to your Capella cluster, please follow the instru
48
48
49
49
Specifically, you need to do the following:
50
50
51
-
Open the `config/couchbase.yml` file and update the connection string, username, password, and bucket name for the development and test environments.
51
+
#### For Development and Test Environments
52
+
53
+
Copy the `dev.env.example` file to `dev.env` and update the connection details:
The application will automatically load these environment variables in development and test environments.
68
+
69
+
#### Configuration File Reference
70
+
71
+
The `config/couchbase.yml` file defines how the application connects to Couchbase:
52
72
53
73
```yml
54
74
common: &common
@@ -109,14 +129,105 @@ The application will run on the port specified by Rails on your local machine (e
109
129
110
130
## Running The Tests
111
131
112
-
The application comes with a set of integration tests that can be run to verify the functionality of the application. The tests are written using RSpec, a popular testing framework for Ruby.
132
+
The application includes two types of tests:
133
+
134
+
### Integration Tests
113
135
114
-
To run the tests, you can use the following command:
136
+
Integration tests verify the actual functionality of the API endpoints. They test the full request-response cycle including database operations.
115
137
116
138
```sh
117
-
bundle exec rspec test/integration
139
+
bundle exec rspec spec/requests/api/v1
118
140
```
119
141
142
+
### Swagger Documentation Tests
143
+
144
+
These tests generate the OpenAPI/Swagger documentation and verify the API contract without performing full integration testing.
145
+
146
+
```sh
147
+
bundle exec rake rswag:specs:swaggerize
148
+
```
149
+
150
+
## Health Check Endpoint
151
+
152
+
The application provides a health check endpoint to monitor the status of the service and its dependencies:
153
+
154
+
```sh
155
+
GET /api/v1/health
156
+
```
157
+
158
+
This endpoint returns the health status of the application and its connection to Couchbase. Example response:
159
+
160
+
```json
161
+
{
162
+
"status": "healthy",
163
+
"timestamp": "2025-12-02T10:30:00Z",
164
+
"services": {
165
+
"couchbase": {
166
+
"status": "up",
167
+
"message": "Connected to Couchbase bucket: travel-sample"
168
+
}
169
+
}
170
+
}
171
+
```
172
+
173
+
You can use this endpoint for monitoring and alerting in production environments.
174
+
175
+
## Troubleshooting
176
+
177
+
### Couchbase ORM Connection Issues
178
+
179
+
If you encounter connection issues with Couchbase ORM, verify the following:
180
+
181
+
1. **Check configuration**: Ensure `config/couchbase.yml` has the correct connection string, username, and password.
182
+
2. **Connection string format**: The connection string should start with `couchbase://` (for non-TLS) or `couchbases://` (for TLS).
183
+
3. **Bucket access**: Verify that the user has read/write permissions to the travel-sample bucket.
184
+
4. **Network connectivity**: Ensure your application can reach the Couchbase cluster on the required ports (typically 8091-8096, 11210).
185
+
186
+
### Common couchbase-orm Errors
187
+
188
+
**Error: `Couchbase::Error::BucketNotFound`**
189
+
- The specified bucket doesn't exist or isn't accessible
190
+
- Solution: Verify the bucket name in `config/couchbase.yml` and ensure the travel-sample bucket is loaded
- Ensure that all tests pass and the new entity's CRUD operations work correctly.
210
333
211
334
By following these steps, you can systematically extend the API functionality with a new entity while maintaining a well-structured and tested codebase.
0 commit comments