Sha256: f564865c51e3caa2b3ecca1ce8cedeb8342ac2457b11855767f3d0b11cf2dd96
Contents?: true
Size: 904 Bytes
Versions: 4
Compression:
Stored size: 904 Bytes
Contents
module WebMock class StubRequestSnippet def initialize(request_stub) @request_stub = request_stub end def body_pattern request_pattern.body_pattern end def to_s(with_response = true) request_pattern = @request_stub.request_pattern string = "stub_request(:#{request_pattern.method_pattern.to_s},".dup string << " \"#{request_pattern.uri_pattern.to_s}\")" with = "".dup if (request_pattern.body_pattern) with << "body: #{request_pattern.body_pattern.to_s}" end if (request_pattern.headers_pattern) with << ",\n " unless with.empty? with << "headers: #{request_pattern.headers_pattern.to_s}" end string << ".\n with(#{with})" unless with.empty? if with_response string << ".\n to_return(status: 200, body: \"\", headers: {})" end string end end end
Version data entries
4 entries across 4 versions & 1 rubygems