2012-08-03 59 views
0

,我有以下鏈接的數據:rspec的磕碰複雜的鏈接方式使用RSpec

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">] 

怎樣一個存根這一點使用RSpec的?

回答

0

使用stub_chain,自然:)

subject.stub_chain(:one, :two, :three).and_return(:four) 
    subject.one.two.three.should eq(:four) 

存根鏈與參數見this answer