RepositoryRubyESTây Ban Nha
ZU

zuazo/dockerspec

A small Ruby Gem to run RSpec and Serverspec, Infrataster and Capybara tests against Dockerfiles or Docker images easily.

180sao
8fork
10issue
3lượt xem

🐳 Dockerspec — Test Dockerfile/Image với RSpec, Serverspec, Infrataster, Capybara

Chạy test hạ tầng và ứng dụng ngay trên Dockerfile hoặc image đã build, không cần triển khai thật — tích hợp sẵn CI/CD.

Dockerspec là một Ruby Gem nhỏ gọn do zuazo phát triển, giúp đội ngũ DevOps và developer viết test tự động cho Dockerfile và Docker image bằng các framework quen thuộc: RSpec (unit/integration), Serverspec (kiểm tra cấu hình server), Infrataster (test HTTP/API qua mạng), và Capybara (test trình duyệt/web). Gem hoạt động out-of-the-box trên Travis CI, CircleCI và các môi trường CI tương tự, phù hợp cho quy trình TDD với container.

✨ Điểm nổi bật

  • Test Dockerfile trực tiếp: docker_build('.') build image từ Dockerfile cục bộ và cho phép assertion về maintainer, cmd, expose, user, v.v.
  • Chạy Serverspec bên trong container: docker_run(described_image) khởi container tạm, áp dụng resource types của Serverspec (file, service, package, port, v.v.) để kiểm tra trạng thái thực tế bên trong.
  • Hỗ trợ Docker Compose: docker_compose spin lên toàn bộ stack, kết hợp its_container('service_name') để test từng service riêng lẻ.
  • Test HTTP/API với Infrataster: Gọi endpoint qua network container, kiểm tra response, header, status code.
  • Test web UI với Capybara: Dùng DSL Capybara (visit, fill_in, click_button) đối với ứng dụng web chạy trong container.
  • Test database qua plugin: Kết hợp infrataster-plugin-mysql để truy vấn MySQL/PostgreSQL trong stack Compose.
  • Retry test flaky: Built-in retry mechanism cho test thất bại tạm thời (network chậm, service chưa ready).
  • Kiểm tra container logs: Assert log output để debug hoặc verify khởi động.
  • Chạy test khác nhau per platform: Phân nhánh test theo OS/arch (linux/amd64, linux/arm64, v.v.).
  • CI/CD ready: Cấu hình mẫu cho Travis CI và CircleCI, không cần setup phức tạp.

💡 Vì sao đáng chú ý

Dockerspec giải quyết bài toán "test infrastructure as code" ở tầng container mà không cần triển khai ra môi trường staging. Thay vì viết script bash kiểm tra thủ công, bạn dùng cú pháp RSpec/Serverspec quen thuộc — expressive, composable, và có báo cáo test chuẩn. Việc hỗ trợ cả Infrataster và Capybara trong cùng một gem cho phép test end-to-end: từ cấu hình OS, service, đến API và UI, tất cả chạy trong container efemeral. Tích hợp Docker Compose nghĩa là bạn test toàn bộ stack (app + db + cache + proxy) như production, nhưng nhanh và isolation. Gem vẫn ở giai đoạn sớm (API có thể breaking giữa minor version), nhưng đã đủ chín cho pipeline CI/CD thực tế.


#Docker #Testing #RSpec #Serverspec #Infrataster #Capybara #DockerCompose #CI/CD #Ruby #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryRuby
inspec/inspec

InSpec: Auditing and Testing Framework

3.1k
Nov 27, 2026
RepositoryRuby
dkhamsing/awesome_bot

:white_check_mark: Validate links in awesome projects

904
Apr 20, 2023
RepositoryRuby
dkhamsing/awesome_bot

:white_check_mark: Validate links in awesome projects

904
Apr 20, 2023
RepositoryGo
docker/compose

Define and run multi-container applications with Docker

39.1k
Nov 26, 2026
RepositoryTypeScript
portainer/portainer

Making Docker and Kubernetes management easy.

38.9k
Nov 27, 2026
RepositoryGo
abiosoft/colima

Container runtimes on macOS (and Linux) with minimal setup

31.9k
Oct 13, 2026
RepositoryGo
quii/learn-go-with-tests

Learn Go with test-driven development

24.0k
Oct 26, 2026
RepositoryJavaScript
mochajs/mocha

☕️ Classic, reliable, trusted test framework for Node.js and the browser

22.9k
Dec 2, 2026
RepositoryC++
catchorg/Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)

21.6k
Nov 23, 2026