ruby on rails - RSpec mocking response attribute -
i'm stuck small issue can't seem find on rspec doc (or elsewhere). suspect it's because it's trying http call unsure.
i'm attempting mock response in controller, actual response coming straight aws-sdk (so it's external service).
controller:
response = { snapshot_id: client.copy_snapshot({foo, bar}).snapshot_id }
is possible stub .snapshot_id?
_spec.rb
before allow(client).to receive(:copy_snapshot).and_return('something') put :update, format: :json puts json.parse(response.body) end
the tests passes without adding .snapshot_id on controller page , can see
{"snapshot_id"=>"something"}
otherwise "this resource unavailable." adding in, i'm lost if i'm doing wrong or if intended behavior.
the reasoning when server on response back, omitting snapshot_id causes server hang amazon returns lot of data (headers, etc)
any appreciated.
Comments
Post a Comment