Sha256: 01e38b8f0178b2fc59c147030aa5899963ab3860824c970c4b0008a345c4d0b6

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8
module PasswordChanger
  class Changer
    private

    attr_reader :website, :show_screenshot_on_error, :viewer

    public

    def initialize(website: 'https://password-portal.example.com', show_screenshot_on_error: true, viewer: 'xdg-open')
      @website                  = website
      @show_screenshot_on_error = show_screenshot_on_error

      Capybara.register_driver :poltergeist do |app|
        options = {
          timeout: 240,
        }

        Capybara::Poltergeist::Driver.new(app, options)
      end

      Capybara.default_driver = :poltergeist

      %w(http_proxy https_proxy).each do |p|
        ENV.delete p
        ENV.delete p.upcase
      end

    end

    def change(user)
      PasswordChanger.logger.debug "The user \"#{user.name}\" has old password \"#{user.old_password}\" and new password \"#{user.new_password}\"."

      user
    end

    private

    def show_page_in_image_viewer
      screenshot_file = Tempfile.new(%w(screenshot .png))
      page.save_screenshot screenshot_file.path
      system("#{Shellwords.escape(viewer)} #{screenshot_file.path}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
password_changer-0.0.4 fixtures/password_changer-test/lib/password_changer-test/changer.rb
password_changer-0.0.3 fixtures/password_changer-test/lib/password_changer/test/changer.rb