You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bin_resolver_spec.rb
    path of file: ./repos/image_optim/spec/image_optim
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require 'spec_helper'
require 'image_optim/bin_resolver'
require 'image_optim/cmd'
require 'image_optim/path'

describe ImageOptim::BinResolver do
  def stub_env(key, value)
    allow(ENV).to receive(:[]).with(key).and_return(value)

    
    def raises_error(error_message)
      5.times do
        expect do
          resolver.resolve!(:the_optimizer)
        end.to raise_error RuntimeError, /#{Regexp.escape(error_message)}/
      end
    end

    context 'presence' do
      let(:exist?){ false }

      it{ raises_error('doesn\'t exist') }
    end

    context 'been a file' do
      let(:file?){ false }

      it{ raises_error('is not a file') }
    end

    context 'been a file' do
      let(:executable?){ false }

      it{ raises_error('is not executable') }
    end
  end