Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby rspec-stubing带rspec的复杂链式方法_Ruby_Ruby On Rails 3_Rspec_Stub - Fatal编程技术网

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)