Skip to content

Instantly share code, notes, and snippets.

View ngty's full-sized avatar

Ng Tze Yang ngty

  • RankAbove Ltd
  • Singapore
View GitHub Profile
###
# Matches an annual leave step like the following in a cucumber feature file:
# "
# Then I should see annual leave "2009-02-20 (afternoon)" with "Status" as "Approved"
# "
#
Then /^I should see annual leave "([^"]+)" with "([^"]+)" as "([^"]+)"$/ do | date_time, label, value |
Then 'I should see annual_leave "%s" with "%s" as "%s" showing "%s" as "%s"' %
[ 'Date/Time', date_time, label, value ]
end
Feature: Create Public Holidays
In order for the system to function as a reasonable HRM
It should support public holidays w.r.t countries
As human resource personnel, I should be able to create public holidays in the system
Scenario Outline: Access "New Public Holiday" Page
Given the following countries exist in the system (...)
| name |
| Singapore |
| Malaysia |
** Invoke features:tag:doing (first_time)
** Invoke db:acceptance:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:acceptance:prepare
** Invoke db:acceptance:load (first_time)
** Invoke db:acceptance:purge (first_time)
** Invoke environment
#!/usr/bin/ruby
`cat ~/.bash_aliases | egrep '^alias' | sed 's/alias//'`.split("\n").each do |line|
parts = line.strip.split(/=/)
name, cmd = parts[0], parts[1].gsub(/('|")/,'')
file = '/home/%s/.config/fish/functions/%s.fish' % [`whoami`.strip, name]
content = [ 'function %s' % name, ' %s $argv;' % cmd, 'end' ].join("\n")
File.open(file, 'w+'){|io| io.write(content) }
end
ActionMailer::Base.class_eval do
DELIVERIES_CACHE_PATH =⋅
File.join(RAILS_ROOT,'tmp','cache','action_mailer_acceptance_deliveries.cache')
def perform_delivery_acceptance(mail)
deliveries << mail
File.open(DELIVERIES_CACHE_PATH,'w') do |f|
Marshal.dump(deliveries, f)
end
module Steam
module Matchers
module HtmlUnit
class HasContent #:nodoc:
# nothing interesting, the original content remains
end
###
# Directly extracted from Webrat::Matchers::HaveXpath with minor edits to avoid
# calling webrat stuff
{:gdb_debug=>true}
=> Hijacking...> (no debugging symbols found)
> Attaching to program: /usr/bin/ruby1.8, process 9433
> Reading symbols from /usr/lib/libruby1.8.so.1.8...(no debugging symbols found)...done.
> Loaded symbols for /usr/lib/libruby1.8.so.1.8
> Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done.
> [Thread debugging using libthread_db enabled]
> [New Thread 0x7fea191b16f0 (LWP 9433)]
> [New Thread 0x7fea14f2f950 (LWP 9852)]
> Loaded symbols for /lib/libpthread.so.0
class LocalTime
@@zone = Time.zone
class << self
def method_missing(method, *args)
args.empty? ? @@zone.send(method) : @@zone.send(method, *args)
end
end
end
@ngty
ngty / power_xpath_for_matching_table_by_th_and_td
Created May 21, 2010 01:52
Single xpath for table cell matching
# This script shows how a single xpath can be used for matching a specific row in an html
# table, taking into account the the header text <th/> and cell text <td/>. It is able to
# handle case-sensitivity & nested inner text.
#
# Pls note that in order to test out case-sensitivity, u need to tweak IS_CASE_SENSITIVE &
# the html string.
#
# BTW, let me know how the generated xpath can be more elegant than it currently is.
#
require 'rubygems'
unless ENV['RAILS_ENV'] == 'production'
module Resque
class << self
alias_method :orig_enqueue, :enqueue
def Resque.enqueue(*args) ; end
end
end
end