Erik A. Hanson's Weblog

Archive for the 'Ruby' Category

SeleniumQuery

Posted: Sunday, May 23rd, 2010    Tags: Ruby, Selenium, jQuery

I wrote a tiny library to make Selenium testing in Ruby a little easier by helping you easily build a jQuery string that can be executed in the browser during a test. This: # this is ruby jquery = SeleniumQuery.new(selenium) id = jquery.find(“td:nth(5).user:visible”).closest(“tr”).attr!(“id”) executes this in the browser: // this is Javascript selenium .browserbot .getCurrentWindow() [...]

A Ruby Client for Angular

Posted: Thursday, November 19th, 2009    Tags: My Software, Ruby, Web development

Here’s a little Ruby client for storing data in Angular, a system for creating simple database-backed web apps extremely easily. #!/usr/bin/ruby require ‘rubygems’ require ‘httpclient’ require ‘json’ class Angular def initialize(username, password, library) @http = HTTPClient.new @library = library post(“/login”, :email => username, :password => password) end def libraries get(“/data”) end def store(database, document, data) [...]

Testing File Uploads To A Rack Server

Posted: Saturday, March 28th, 2009    Tags: Howto, Ruby

I wrote a web app on top of Rack that includes the ability to accept file uploads. It took some time to figure out how to successfully test the file upload using Rack::Test. The trick was to encode the file exactly correctly, and then post it with the correct headers. I wrote a simple post_file [...]