Search code examples
ruby-on-railsdebuggingrspecrspec-railspry

How to examine rspec variables with pry debugger


I've seen some SO posts explaining how to use pry to step into rspec tests and been able to do this. Once I reach the breakpoint though, I'm struggling to display any useful information. For this code below, I'd like to examine the response object from the pry console:

describe 'happenings' do
  context "#index (GET /api/v1/flat_happenings.json)" do
    before(:each) do
      30.times { FactoryGirl.create(:flat_happening) }
      get "/api/v1/flat_happenings.json"
    end
    describe "should list all flat_happenings" do
      binding.pry
      it { JSON.parse(response.body)["flat_happenings"].length.should eq 30 }
    end
  end
end

Any ideas on how to do this?


Solution

  • You should place binding.pry inside it block.