Guard::Spork 项目技术文档
1. 安装指南
在开始使用 Guard::Spork 之前,请确保已经安装了 Guard。Guard::Spork 是一个用于自动启动和重载 RSpec/Cucumber/Test::Unit 的 Spork 服务器的工具。
安装步骤
-
安装 Guard: 如果你还没有安装
Guard,请先安装:$ gem install guard -
安装 Guard::Spork: 使用以下命令安装
Guard::Spork:$ gem install guard-spork -
添加到 Gemfile: 将
guard-spork添加到你的 Gemfile 的development组中:group :development do gem 'guard-spork' end -
生成 Guardfile: 使用以下命令将
guard-spork的配置添加到你的Guardfile中:$ guard init spork
2. 项目的使用说明
基本用法
Guard::Spork 的主要功能是自动启动和重载 Spork 服务器。你可以通过 Guard 的命令行工具来启动 Guard::Spork:
$ guard
Guardfile 配置
在 Guardfile 中,你需要确保 Spork 的 guard 定义在 RSpec/Cucumber/Test::Unit 的 guard 之前。以下是一个典型的 Rails 应用的 Guardfile 配置示例:
guard 'spork' do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.*\.rb$})
watch(%r{^config/initializers/.*\.rb$})
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
end
通过 Spork 运行测试
为了通过 Spork 的 DRb 服务器运行测试,你需要在 Guard::RSpec 和 Guard::Cucumber 的配置中添加 :cmd => "rspec --drb" 选项:
guard 'rspec', :cmd => "rspec --drb" do
# ...
end
guard 'cucumber', :cmd => "rspec --drb" do
# ...
end
对于 MiniTest,你需要添加 :drb => true 选项:
guard 'minitest', :drb => true do
# ...
end
3. 项目API使用文档
选项配置
Guard::Spork 提供了多种选项来定制其行为。以下是一些常用的选项:
:rspec => false:禁用 RSpec 支持。:cucumber => false:禁用 Cucumber 支持。:test_unit => false:禁用 Test::Unit 支持。:bundler => false:不使用bundle exec。:rspec_env、:cucumber_env、:test_unit_env:为 RSpec、Cucumber 和 Test::Unit 提供额外的环境变量。:foreman => true:使用 Foreman 启动 Spork,并传递.env文件中的环境变量。
示例:
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'cucumber' }, :rspec_env => { 'RAILS_ENV' => 'test' }, :test_unit_env => { 'RAILS_ENV' => 'test' } do
# ...
end
常见问题排查
如果你手动启动 Spork 成功,但通过 Guard::Spork 启动时出现错误,可以尝试增加 :wait 选项的值,例如:
guard 'spork', :wait => 60 do
# ...
end
4. 项目安装方式
Guard::Spork 的安装方式非常简单,只需按照以下步骤操作:
- 确保已安装
Guard。 - 使用
gem install guard-spork命令安装Guard::Spork。 - 将
guard-spork添加到 Gemfile 的development组中。 - 使用
guard init spork命令生成Guardfile配置。
通过以上步骤,你就可以成功安装并配置 Guard::Spork,开始使用它来自动化你的测试环境。
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust099- DDeepSeek-V4-ProDeepSeek-V4-Pro(总参数 1.6 万亿,激活 49B)面向复杂推理和高级编程任务,在代码竞赛、数学推理、Agent 工作流等场景表现优异,性能接近国际前沿闭源模型。Python00
MiMo-V2.5-ProMiMo-V2.5-Pro作为旗舰模型,擅⻓处理复杂Agent任务,单次任务可完成近千次⼯具调⽤与⼗余轮上 下⽂压缩。Python00
GLM-5.1GLM-5.1是智谱迄今最智能的旗舰模型,也是目前全球最强的开源模型。GLM-5.1大大提高了代码能力,在完成长程任务方面提升尤为显著。和此前分钟级交互的模型不同,它能够在一次任务中独立、持续工作超过8小时,期间自主规划、执行、自我进化,最终交付完整的工程级成果。Jinja00
Kimi-K2.6Kimi K2.6 是一款开源的原生多模态智能体模型,在长程编码、编码驱动设计、主动自主执行以及群体任务编排等实用能力方面实现了显著提升。Python00
MiniMax-M2.7MiniMax-M2.7 是我们首个深度参与自身进化过程的模型。M2.7 具备构建复杂智能体应用框架的能力,能够借助智能体团队、复杂技能以及动态工具搜索,完成高度精细的生产力任务。Python00