mardi 16 mai 2017

puts and binding.pry output is not visible in test environment

I use minitest and rake task to run tests. I use standard reporter (this is from test helper):

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
)

This is my 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

I also have pry installed in Gemfile:

group :pry, :test do
  gem 'pry-rails'
  gem 'pry-byebug'
end

The problem I can't use it in tests. I can add a breakpoint with binding_pry, but I don't see the output from invoked functions. I can't also log anything using puts (from both pry and directly from tests). I don't see this output nor in terminal nor in log files. The only thing I can use at the moment is a Rails logger. But it's not satysfying. How can I display output from pry and puts in terminal?

Aucun commentaire:

Enregistrer un commentaire