Created
August 24, 2012 23:24
-
-
Save danpariente/3457126 to your computer and use it in GitHub Desktop.
Automated User Chat Room Creator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
class ChatRoomConnector | |
attr_accessor :generated_password, :username, :email | |
def initialize(username) | |
@username = username | |
@email = "" | |
@generated_password = "" | |
@agent = Mechanize.new | |
@page = @agent.get('http://jobsteroom.herokuapp.com/users/sign_up') | |
end | |
def create_room | |
email = "#{username}_#{((1000001+rand(999)).to_s + (1+rand(8)).to_s).reverse.to_i.to_s(36)}@jobster.com" | |
generated_password = Digest::SHA1.hexdigest(Time.now.to_s + username)[0..9] | |
room_form = @page.form | |
room_form.fields[2].value = email | |
room_form.fields[3].value = generated_password | |
room_form.fields[4].value = generated_password | |
@agent.submit(room_form, room_form.buttons.first) | |
return %Q{<br />Join the interviewer in the correspondent chatroom | |
<a href="http://jobsteroom.heroku.com" target="_blank">http://jobsteroom.heroku.com</a> | |
using the following data:<br /> | |
your email: #{email}<br /> | |
password: #{generated_password}<br /> | |
Thank You. | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment