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
,开始使用它来自动化你的测试环境。
鸿蒙开发工具大赶集
本仓将收集和展示鸿蒙开发工具,欢迎大家踊跃投稿。通过pr附上您的工具介绍和使用指南,并加上工具对应的链接,通过的工具将会成功上架到我们社区。012hertz
Go 微服务 HTTP 框架,具有高易用性、高性能、高扩展性等特点。Go01每日精选项目
🔥🔥 每日精选已经升级为:【行业动态】,快去首页看看吧,后续都在【首页 - 行业动态】内更新,多条更新哦~🔥🔥 每日推荐行业内最新、增长最快的项目,快速了解行业最新热门项目动态~~029kitex
Go 微服务 RPC 框架,具有高性能、强可扩展的特点。Go00Cangjie-Examples
本仓将收集和展示高质量的仓颉示例代码,欢迎大家投稿,让全世界看到您的妙趣设计,也让更多人通过您的编码理解和喜爱仓颉语言。Cangjie057毕方Talon工具
本工具是一个端到端的工具,用于项目的生成IR并自动进行缺陷检测。Python040PDFMathTranslate
PDF scientific paper translation with preserved formats - 基于 AI 完整保留排版的 PDF 文档全文双语翻译,支持 Google/DeepL/Ollama/OpenAI 等服务,提供 CLI/GUI/DockerPython06mybatis-plus
mybatis 增强工具包,简化 CRUD 操作。 文档 http://baomidou.com 低代码组件库 http://aizuda.comJava03国产编程语言蓝皮书
《国产编程语言蓝皮书》-编委会工作区018- DDeepSeek-R1探索新一代推理模型,DeepSeek-R1系列以大规模强化学习为基础,实现自主推理,表现卓越,推理行为强大且独特。开源共享,助力研究社区深入探索LLM推理能力,推动行业发展。【此简介由AI生成】Python00
热门内容推荐
最新内容推荐
项目优选









