gpt4 book ai didi

ruby - 在 autotest 或 Guard 下安装、配置和运行 minitest 的简明方法

转载 作者:太空宇宙 更新时间:2023-11-03 18:22:41 33 4
gpt4 key购买 nike

过去,我运行过 Rails + RSpec + 自动测试。现在我已经升级到 ruby​​ 2.0,我想在非 Rails 环境中使用 minitest(我正在使用 Padrino/DataMapper)。我敢肯定,我不是唯一想要这个的人。

真正有用的是安装和配置东西的简明秘诀,所以简单的命令:

$ autotest

$ bundle exec guard

将开始测试/test 下的所有内容。我已经搜索过 SO 和 InterWebs,但还没有找到这样的食谱。食谱应包括:

  • 您应该在 Gemfile 中包含哪些 gem?
  • 您运行什么命令来设置环境?
  • 您需要创建哪些配置和支持文件(Rakefile?.autotest?等...)
  • 测试文件需要'test_helper'处理重复功能的方法

展示如何为完整的 XP 体验配置 growl 和 spork 的额外功劳!

最佳答案

嗯,我不使用自动测试,现在看来 Guard 最合适,所以:

# Add to Gemfile
group :development do
gem 'terminal-notifier-guard' # or libnotify for linux
gem 'rb-fsevent', require: false # or rb-inotify for linux
gem 'guard-minitest'
gem 'minitest'
end

# From bash
$ bundle update
$ guard init minitest # or bundle exec guard init minitest

# Edit the GuardFile, mine looks like:
guard 'minitest' do
# with Minitest::Unit
watch(%r|^test/(.*)\/?test_(.*)\.rb|)
watch(%r|^app/models/(.*)\.rb|) { |m| "test/test_#{m[1]}.rb" }
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/test_#{m[2]}.rb" }
watch(%r|^test/helper\.rb|) { 'test' }
end

# Here my test helper.rb. /test/helper.rb
ENV['PADRINO_ENV'] ||= 'test'
require_relative '../config/boot'
require 'minitest/autorun'


# Have fun!
$ bundle exec guard

关于ruby - 在 autotest 或 Guard 下安装、配置和运行 minitest 的简明方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15575952/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com