 This pilot phase III trial studies the side effects and best dose of olaparib when given together with ramucirumab and how well they work in treating patients with gastric or gastroesophageal junction cancer that has spread to other places in the body, has come back, or cannot be removed by surgery. Olaparib may stop the growth of tumor cells by blocking some of the enzymes needed for cell growth. Monoclonal antibodies, such as ramucirumab, may interfere with the ability of tumor cells to grow and spread. Giving olaparib and ramucirumab may work better in treating patients with gastric or gastroesophageal junction cancer. 