我目前正在为我的Rails控制器编写规范。我似乎无法让任何puts语句、binding.pry或binding.remote_pry工作。
我能够让远程撬在开发环境中工作。
group :development, :test do
gem 'rspec-rails', '~> 3.0'
gem 'capybara'
gem 'factory_girl_rails'
gem 'daemons'
gem 'pry-rails'
gem 'pry-remote'
gem 'binding_of_caller'
end发布于 2015-06-04 09:47:27
在调用测试环境之前,似乎需要在测试环境中的某个地方进行require 'pry'。您的spec_helper.rb、test_helper.rb或类似的地方可能是个不错的地方。
发布于 2022-07-14 04:15:26
这完全归功于@Dan,这里是我放置require 'pry'的地方(请注意,前9行是新安装的rspec附带的代码):
# specs/rails_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
require 'pry' # <----- HEREhttps://stackoverflow.com/questions/28444357
复制相似问题