Skip to content

Instantly share code, notes, and snippets.

View awesome's full-sized avatar

So Awesome Man awesome

View GitHub Profile
Then(/^I should be at (.+?) page$/) do |page_name|
request.path.should =~ /^#{path_to(page_name + " page")}/
end
# @member is set by a factory before reaching this step
Then /^I should be at edit_member page$/ do
response.request.env["REQUEST_URI"].should contain("/members/#{@member.id}/edit")
end
# this better
Then /^I should be at no_access page$/ do
response.request.env["REQUEST_URI"].should == "/no_access"
end
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
# http://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby
# Kent Fredric:
(0...8).map{65.+(rand(25)).chr}.join
# I spend too much time golfing.
(0...50).map{ ('a'..'z').to_a[rand(26)] }.join
# For lots of good WTFBBQ factor.
# And one more that's even more confusing, but more flexible and wastes less cycles:
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
@awesome
awesome / gist:186376
Created September 13, 2009 23:43 — forked from mwunsch/gist:109799
require 'nokogiri'
# = XmlMini Nokogiri implementation
module ActiveSupport
module XmlMini_Nokogiri #:nodoc:
extend self
# Parse an XML Document string into a simple hash using libxml / nokogiri.
# string::
# XML Document string to parse
require 'rubygems'
require 'active_support'
# from XML to Hash
Hash.from_xml(xml_string) # => Hash
# from Hash to XML
{1=>2,3=>4}.to_xml # => "XML" String
@awesome
awesome / gsub unhyperlink
Created September 22, 2009 18:50
auto unhyperlink links
@awesome
awesome / list_attr_accessor
Created September 24, 2009 19:42
list attr_accessors
# there may be a better way that is not ghetto,
# however I will show you how to list attr_accessors,
# actually have them returned as strings in an array:
class Awesome
attr_accessor :beer, :chips, :mullet
def initialize
@awesome = "dude"
end
end