Skip to content

Instantly share code, notes, and snippets.

View DylanLacey's full-sized avatar

The Gentlehacker DylanLacey

View GitHub Profile
@DylanLacey
DylanLacey / gist:1366419
Created November 15, 2011 07:54
jquery shizzle
new_input = $('<input type="hidden">', {
name: "job_" + pickup + '[]',
text: $("#element").val + 'order : ' + index
});
class Waypoint < ActiveRecord::Base
belongs_to :address
belongs_to :job
# validates_presence_of :location_name, :if => proc { | wp | wp.friendly_name.nil? || (wp.friendly_name.blank? && wp.friendly_name.empty?)}
validates_presence_of :suburb_name
# Street is a composite class because that allows for .accessing
class ChangeTypeOfWaypointKeys < ActiveRecord::Migration
def up
#the damn migration wasn't running, so am dropping altogether
change_table :waypoints do |t|
t.remove :street_key, :suburb_key, :designation_key
t.string :street_key, :suburb_ley, :designation_key
end
end
def down
task "cut_gem" do
version:bump:patch
end
rule /^version:bump:.*/ do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(t.name.split(':').last)
file = 'lib/GEM_NAME/version.rb'
@DylanLacey
DylanLacey / gist:2723260
Created May 18, 2012 05:03
Uglyarse code
require "MTDataStone"
class BookingRehydrator
@fleet_map = {
:sydney => :sydney,
:brisbane => nil
}
def self.rehydrate
@DylanLacey
DylanLacey / Test Results
Created October 17, 2012 04:54
Testing Code, Results
C:\jruby\jruby-1.7.0.preview1\bin\jruby.exe --1.9 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Projects/MTDataStone/test/unit/place_test.rb
Testing started at 2:52 PM ...
Checking #<Place:0x25343815> == #<Place:0x74dfdc8>
Responds
Checking #<Place:0x25343815> == ENV
Checking #<Place:0x74dfdc8> == ENV
Checking #<Place:0x25343815> == ENV
Checking #<Place:0x74dfdc8> == ENV
Checking #<Place:0x25343815> == ENV
Checking #<Place:0x74dfdc8> == ENV
@DylanLacey
DylanLacey / gist:3977844
Created October 30, 2012 01:48
MTData Consistent AR
module MTData
module CityNamespaceMixin
def self.included(base)
base.establish_connection "mtdata"
base.table_name = "#{$CITY_NAME}].[dbo].[Place"
end
end
class Perth
$CITY_NAME = "Perth"
@DylanLacey
DylanLacey / gist:4541602
Created January 15, 2013 20:12
Suggested config
@selenium = Sauce::Selenium2.new(:"selenium-version" => "2.3.0", :job_name => "CCQ - TEST")
@DylanLacey
DylanLacey / with_capybara.rb
Created February 8, 2013 05:05
How to set the name of your tests for Selenium::WebDriver & Sauce Labs, in Ruby. Lots of other things can be set this way, check out https://saucelabs.com/docs/additional-config under the "Job Annotation" heading.
# Where you create your WebDriver object, set a "name" key-value pair to name a test:
Capybara.register_driver :selenium do |app|
require 'selenium-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
capabilities[:name] = "Some Sort Of Test"
Capybara::Selenium::Driver.new(app, {
:url => "http://username:[email protected]:80/wd/hub",
@DylanLacey
DylanLacey / with_capybara_for_remote.rb
Last active December 14, 2015 00:59
How to use Sauce Labs with Capybara only for remote tests (with :js => true)
# Include this in spec_helper when you're running remotely
Capybara.register_driver :selenium do |app|
require 'selenium-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
Capybara::Selenium::Driver.new(app, {
:url => "https://sauce_username:[email protected]:80/wd/hub",
:browser => :remote,