Pro*_*der 19 debugging rspec ruby-on-rails rspec-rails pry
我已经看到一些SO帖子解释了如何使用pry进入rspec测试并且能够做到这一点.一旦我到达断点,我就很难显示任何有用的信息.对于下面的代码,我想从pry控制台检查响应对象:
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
关于如何做到这一点的任何想法?
这应该有效:
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
    it "should list all flat_happenings" do
      binding.pry
      JSON.parse(response.body)["flat_happenings"].length.should eq 30
    end
  end
end
华泰
| 归档时间: | 
 | 
| 查看次数: | 14057 次 | 
| 最近记录: |