Reputation: 1352
I'm currently writing specs for my Rails controller. I can't seem to get any puts statement or binding.pry, or binding.remote_pry working.
I am able to get the remote pry working in the development environment.
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
Upvotes: 7
Views: 7552
Reputation: 52817
All credit to @Dan, here's where I placed require 'pry'
(note that the first 9 lines are what comes with a fresh install of 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' # <----- HERE
Upvotes: 0
Reputation: 925
It seems that you need to require 'pry'
somewhere in your test environment before invoking it. Your spec_helper.rb
, test_helper.rb
or similar is probably a good place.
Upvotes: 9