binding.pry ignored by rspec
Asked Answered
F

0

7

I am expecting a pry session to be opened in my console during execution of rspec. Am I doing something incorrect? Or expecting the wrong behavior?

Gemfile:

group :development, :test do
  gem 'rspec'
  gem 'rspec-rails'
  ...
  gem 'pry-rails'
  ...
end

Gemfile.lock:

...
pry (0.10.0)
...
rspec-rails (3.0.1)

spec:

require 'rails_helper'

RSpec.describe Account, type: :model, do
  let!(:acct) { FactoryGirl.create(:account) }

  describe '#hash' do
    it 'should ...' do
      acct.property = 5
      binding.pry
      expect(acct).to_not be_nil
    end
  end

end

console:

% rspec
...
Failed examples: 
...
Randomized with seed 59654
Fanya answered 19/6, 2014 at 16:38 Comment(6)
gem 'pry-rescue' does the trick, but I would still like to know what I am doing wrong.Fanya
Are you positive that spec is running? You have 3 specs in your output -- maybe the file isn't named _spec.rb or something unusually like that? Just to make sure I'd try a puts "should open pry" or similar right before that just as a check for something crazy :)Hibbler
Could you make a minimal reproducible app on somewhere for people to clone and investigate further? Thanks!Please
Are you sure you are getting past the `acct.property = 5`` statement?Imf
Have you tried require 'pry'?Suzannsuzanna
I am using byebug gem and it works fine during tests. You need only include gem 'byebug' in Gemfile and call "debugger" at the point you want to debugBurgeon

© 2022 - 2024 — McMap. All rights reserved.