module SignatureHelper
  def draw_signature(file, signature_field_id)
    data_uri = ActionController::Base.helpers.escape_javascript(Base64Image.from_image(file).data_uri)
    page.execute_script <<-JS
      $("##{signature_field_id}").val("#{data_uri}")
    JS
  end
end

RSpec.configure do |config|
  config.include SignatureHelper
end
