Ruby rspec-stubing带rspec的复杂链式方法
我有以下链接数据:Ruby rspec-stubing带rspec的复杂链式方法,ruby,ruby-on-rails-3,rspec,stub,Ruby,Ruby On Rails 3,Rspec,Stub,我有以下链接数据: Data::Universal.find("501c2599dc1c82704e000037").data.last.foo => [#<Data::Universal::Foo::ErrorMessage _id: 501c24f1dc1c82704e000014, _type: "Data::Universal::Foo::ErrorMessage", created_at: nil, updated_at: nil, is_enabled: true, l
Data::Universal.find("501c2599dc1c82704e000037").data.last.foo
=> [#<Data::Universal::Foo::ErrorMessage _id: 501c24f1dc1c82704e000014, _type: "Data::Universal::Foo::ErrorMessage", created_at: nil, updated_at: nil, is_enabled: true, left_px: 1, top_px: 1, width_px: 420, height_px: 198, inner_width: nil, inner_height: nil, z_index: 1000, position: nil, name: nil, custom_css: "", element_label: "Error Message ", can_be_deleted: true, sticky: false, sticky_eigenscreen: "top", sticky_screens: [], audience_id: "", can_be_spatially_edited: false, editable_left_px_setting: true, editable_top_px_setting: true, editable_width_px_setting: true, editable_height_px_setting: true, version: nil, modifier_id: nil, primary_color: "#6D84B4", primary_border_color: "#29447E", secondary_color: "#F2F2F2", screen_id: "4f9058772774e2279200004d">]
Data::Universal.find(“501c2599dc1c82704e000037”).Data.last.foo
=> [#]
如何使用rspec来存根呢?自然地使用:)
有关带参数的短链,请参见
subject.stub_chain(:one, :two, :three).and_return(:four)
subject.one.two.three.should eq(:four)