Skip to content

Instantly share code, notes, and snippets.

@bash0C7
Created November 12, 2013 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bash0C7/7432700 to your computer and use it in GitHub Desktop.
Save bash0C7/7432700 to your computer and use it in GitHub Desktop.
Web serfing with Webrat
require 'webrat'
require 'mechanize'
class Hoge
Webrat.configure do |config|
config.mode = :mechanize
end
include Webrat::Methods
def initialize login_page_url, user_id, password
visit login_page_url
fill_in "login_id", :with => user_id
fill_in "login_password", :with => password
click_button "login!!"
end
#serf(%w{http://example.com/hoge}) {|url, page| puts "#{url}\t#{/some_string/ =~ page.content ? :o : :x}"}
def serf target_urls
target_urls.each {|url| yield url, visit(url)}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment