Skip to content

Instantly share code, notes, and snippets.

View oriolgual's full-sized avatar

Oriol Gual oriolgual

View GitHub Profile
@oriolgual
oriolgual / capybara_select_dates_and_times.rb
Created September 9, 2011 08:40 — forked from szimek/capybara_select_dates_and_times.rb
Cucumber steps for selecting time and date (using Capybara)
require "xpath" # XPath is a separate gem now
module Cucumber
module Rails
module CapybaraSelectDatesAndTimes
def select_date(field, options = {})
date = Date.parse(options[:with])
find(:xpath, %Q{//select[contains(@id, "#{field}_1i")]}).find(:xpath, ::XPath::HTML.option(date.year.to_s)).select_option
find(:xpath, %Q{//select[contains(@id, "#{field}_2i")]}).find(:xpath, %Q{option[@value='#{date.month.to_s}']}).select_option
find(:xpath, %Q{//select[contains(@id, "#{field}_3i")]}).find(:xpath, ::XPath::HTML.option(date.day.to_s)).select_option
@oriolgual
oriolgual / devise.ca.yml
Created June 1, 2011 13:47 — forked from jrom/devise.ca.yml
Catalan translation for Devise
ca:
errors:
messages:
expired: "ha caducat, demanen un de nou"
not_found: "no s'ha trobat"
already_confirmed: "ja està confirmat"
not_locked: "no està bloquejat"
not_saved:
one: "1 error ha evitat que %{resource} es pugui desar:"
other: "%{count} errors han evitat que %{resource} es pugui desar:"
@oriolgual
oriolgual / benchmark.rb
Created March 21, 2011 12:52 — forked from wbailey/benchmark.rb
Use with plain Ruby
require 'rubygems'
require 'benchmark'
include Benchmark
class Array
def to_hash_using_inject_push( use_array )
Hash[*(0 .. self.size).inject( [] ) { |r,i| r.push( self[i], use_array[i] ) }]
end