oesmith / puffing-billy

A rewriting web proxy for testing interactions between your browser and external sites. Works with ruby + rspec.
MIT License
656 stars 170 forks source link

question: mocking images #292

Closed aharbick closed 4 years ago

aharbick commented 4 years ago

I've been hunting for some examples... I have an app that uses S3 to store images. It would be nice to mock requests and return actual images that could be asserted in capybara, and visual tests in percy would be consistent.

Thoughts?

aharbick commented 4 years ago

NVM... I figured it out.

Billy.proxy.stub(/some_image_path/).and_return(
      headers: {
        'Content-type' => 'image/png',
        'Access-Control-Allow-Origin' => '*'
      },
      body: IO.read("/path/to/stub-image.png"),
      code: 200
    )