require 'helper'
class TestRequest < Test::Unit::TestCase
def test_initializes_receiving_data_and_optional_id
request = MyMoip::Request.new("request_id")
assert_equal "request_id", request.id
end
def test_logs_api_call_method
logger = stub_everything
request = MyMoip::Request.new("request_id")
params = {
http_method: :post, body: "", path: "/ws/alpha/EnviarInstrucao/Unica"
}
HTTParty.stubs(:send).returns("some_result")
logger.expects(:info).at_least_once.
with(regexp_matches(/request_id.+some_result<\/html>/))
request.api_call(params, logger)
end
def test_logs_api_call_response
logger = stub_everything
request = MyMoip::Request.new("request_id")
params = {
http_method: :post, body: "", path: "/ws/alpha/EnviarInstrucao/Unica"
}
HTTParty.stubs(:send).returns("some_result")
logger.expects(:info).at_least_once.
with(regexp_matches(/request_id.+some_result<\/html>/))
request.api_call(params, logger)
end
end