This file contains 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
Then(/^I should be at (.+?) page$/) do |page_name| | |
request.path.should =~ /^#{path_to(page_name + " page")}/ | |
end |
This file contains 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
# @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 |
This file contains 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
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 |
This file contains 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
# 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: |
This file contains 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
#!/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' |
This file contains 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
=== 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 |
This file contains 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 '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 |
This file contains 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 'active_support' | |
# from XML to Hash | |
Hash.from_xml(xml_string) # => Hash | |
# from Hash to XML | |
{1=>2,3=>4}.to_xml # => "XML" String |
This file contains 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
def unhyperlink(string) | |
string.gsub(/<a[^>]*>([^<]+)<\/a>/i, '\1') | |
end | |
#example | |
string = "get glue now at <a href="http://glue.gs" rel="awesome">http://glue.gs</a>" | |
unhyperlink(string) # => "get glue now at http://glue.gs" |
This file contains 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
# 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 |