I am trying to write the rspec specification to verify that my logic can handle a specific Net :: HTTPResponse that has a 401 status code. Since I use HTTParty, .get will return me HTTPartyResponse, ll get Net :: HTTPResponse with httparty_repsonse_object.response.
net_response_object = Net::HTTPResponse.new(1.1, 401, 'Forbidden') #not sure what to do here? write a test double to return a net_response_object? stub_request(:any, /hello.com/).to_return(a_http_party_response_object)
I realized that this is the right way
it 'will test this' do stub_request(:any, /hello.com/).to_return(:status => [401, "Forbidden"]) ... end
HTTParty should parse the HTTP push response and return an HTTPartyResponse to me.
You can use Webmock , which supports mocking HTTParty requests.
Source: https://habr.com/ru/post/918889/More articles:help with OCR - Matlab - image-processingCreating a JTextArea or JEditorPane in a scrollable JFrame - javaImage processing on CUDA or OpenCV? - image-processingShredding data from XML, importing into relational tables (SQL Server 2008) - xmlTest version - twitter-bootstrapPorting a Qt-based application in Android - androidhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/918891/aggregating-multiple-test-cases-from-multiple-modules-to-run-in-pydev-testrunner&usg=ALkJrhj0lAqOet44NcAqqM65EYZx7dtezAHDF5 C code generation - ccreating subprojects in bottles - pythonHow many string objects will be created in memory? - javaAll Articles