This file contains hidden or 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 'rubygems' | |
require 'cucumber' | |
require 'xmlrpc/client' | |
# a hacky way to combine outputs to several io devices | |
class IoMerger | |
attr_accessor :other_ios | |
def initialize(base_io) | |
@base_io = base_io |
This file contains hidden or 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
Given "I am on the Twitter home page" do | |
@home_page.visit | |
end | |
Given "I see the most popular topic" do | |
@most_popular = @home_page.most_popular_topic | |
puts "Most popular topic: '#{@most_popular}'" | |
end | |
When "I visit the Twitter home page" do |
This file contains hidden or 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
class TwitterHomePage | |
PAGE_URL = "http://www.twitter.com" | |
def initialize(world) | |
@world = world | |
@browser = $selenium_helper.browser | |
end | |
def visit | |
@browser.open PAGE_URL | |
@browser.wait_for_page_to_load |
This file contains hidden or 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
selenium.browser.name=*firefox | |
selenium.port=4444 |
This file contains hidden or 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 'selenium/client' | |
require 'selenium/rspec/spec_helper' | |
require File.join(BASEDIR,'support/user_config.rb') | |
if defined? JRUBY_VERSION | |
# jruby has it's own process-handling code, as 'fork' is unreliable in java | |
require 'java' | |
end | |
class SeleniumHelper |
This file contains hidden or 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
BASEDIR = File.join(File.dirname(__FILE__),"..") unless defined? BASEDIR | |
PRJDIR = File.join(File.dirname(__FILE__),"..","..","..") unless defined? PRJDIR | |
require 'spec/expectations' # rspec extras | |
require File.join(BASEDIR,'support/selenium_helper.rb') | |
require File.join(BASEDIR,'support/user_config.rb') | |
# globals - keep these to a minimum! | |
$user_config = UserConfig.new | |
$selenium_helper = SeleniumHelper.new($user_config) # better a global than a singleton - still need something global as it's used in monkey-patching bits below |
This file contains hidden or 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
selenium.browser.name=*firefox | |
selenium.port=4444 |
This file contains hidden or 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
class KornyHanoi | |
def initialize(options={:discs => 8}) | |
@discs = options[:discs] | |
@all_pegs = [:from, :pivot, :to] | |
@pegs = {:from => [], :to => [], :pivot => []} | |
@discs.downto(1) do |num| | |
@pegs[:from] << num | |
end | |
end |
This file contains hidden or 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 'java' | |
require 'pp' | |
import "org.apache.poi.hssf.usermodel.HSSFWorkbook" | |
import "org.apache.poi.hssf.usermodel.HSSFSheet" | |
import "org.apache.poi.hssf.usermodel.HSSFRow" | |
import "org.apache.poi.hssf.usermodel.HSSFCell" | |
import "java.io.FileInputStream" | |
import "java.io.FileOutputStream" |
This file contains hidden or 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
p = new ProgressLogger(count=1000000) | |
( state => println("Processed " + state.count + "rows")) | |
collection.foreach( | |
record => ( | |
p.trigger | |
// do stuff | |
) | |
) |
OlderNewer