【发布时间】:2017-05-17 00:58:54
【问题描述】:
我使用 minitest 和 rake 任务来运行测试。我使用标准记者(这是来自测试助手):
Minitest::Reporters.use!(
Minitest::Reporters::DefaultReporter.new(fast_fail: true, slow_count: 3),
# show single tests with the spec reporter
# MiniTest::Reporters::SpecReporter.new,
ENV, Minitest.backtrace_filter
)
这是我的 test.rake:
require 'rake/testtask'
Rake::Task['test:run'].clear
Rake::Task['test:decorators'].clear
namespace :test do
task run: ['test:decorators', 'test:models', 'test:controllers', 'test:mailers', 'test:integration']
Rake::TestTask.new(decorators: 'test:prepare') do |t|
t.pattern = 'test/decorators/**/*_test.rb'
end
end
我还在 Gemfile 中安装了 pry:
group :pry, :test do
gem 'pry-rails'
gem 'pry-byebug'
end
我无法在测试中使用它的问题。我可以用binding_pry 添加断点,但我看不到调用函数的输出。我也无法使用puts 记录任何内容(来自撬动和直接来自测试)。我在终端和日志文件中都没有看到这个输出。目前我唯一可以使用的是 Rails 记录器。但这并不令人满意。如何在终端中显示 pry 和 puts 的输出?
【问题讨论】:
标签: ruby-on-rails testing stdout minitest puts