首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在测试环境中不调用绑定撬

在测试环境中不调用绑定撬
EN

Stack Overflow用户
提问于 2015-02-11 00:17:19
回答 2查看 5.9K关注 0票数 6

我目前正在为我的Rails控制器编写规范。我似乎无法让任何puts语句、binding.pry或binding.remote_pry工作。

我能够让远程撬在开发环境中工作。

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-04 09:47:27

在调用测试环境之前,似乎需要在测试环境中的某个地方进行require 'pry'。您的spec_helper.rbtest_helper.rb或类似的地方可能是个不错的地方。

票数 9
EN

Stack Overflow用户

发布于 2022-07-14 04:15:26

这完全归功于@Dan,这里是我放置require 'pry'的地方(请注意,前9行是新安装的rspec附带的代码):

代码语言:javascript
复制
# 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' # <----- HERE
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28444357

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档