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
module LastRequestResponse | |
def last_request | |
page.driver.last_request | |
end | |
def last_response | |
page.driver.last_response | |
end | |
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
# pm - Print methods of objects in irb/console sessions. | |
# Goes in ~./irbrc | |
# | |
begin # Utility methods | |
def pm(obj, *options) # Print methods | |
methods = obj.methods | |
methods -= Object.methods unless options.include? :more | |
filter = options.select {|opt| opt.kind_of? Regexp}.first | |
methods = methods.select {|name| name =~ filter} if filter |
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
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile.add_extension("/path/to/firebug.xpi") | |
driver = Selenium::WebDriver.for :firefox, :profile => profile |
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
images = @album.image_assignments | |
changed = Array.new | |
# Get the images that changed order | |
for image in images | |
order = params["order_#{image.image_id}".to_sym] | |
if !order.blank? && order =~ /^\d+$/ && image.position.to_i != order.to_i | |
image.position = order.to_i | |
changed << image |
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 /^"([^"]*)" from "([^"]*)" within "([^"]*)" should be disabled$/ do |option_name, type_label, selector| | |
with_scope(selector) do | |
x=page.find(:xpath, '//body').all(:xpath, XPath.generate { |x| x.descendant(:select).descendant(:option)[x.attr(:disabled) == 'disabled'] }) | |
x.collect(&:text).should include(option_text) | |
end | |
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
# Locates a table cell based on given row and column content. | |
When /^(.*) in the "([^\"]*)" column of the "([^\"]*)" row$/ do |action, column_title, row_title| | |
col_number = 0 | |
all(:xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{column_title}')]]/th").each do |element| | |
col_number += 1 | |
break if element.has_content?(column_title) | |
end | |
within :xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{row_title}')]]/td[#{col_number}]" do | |
When action | |
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
# put in config/application.rb | |
config.to_prepare do | |
::PagesController.module_eval do | |
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
end | |
::Page.module_eval do | |
after_save :clear_static_caching! | |
after_destroy :clear_static_caching! |
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
# put in config/application.rb | |
config.to_prepare do | |
::PagesController.module_eval do | |
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
end | |
::Page.module_eval do | |
after_save :clear_static_caching! | |
after_destroy :clear_static_caching! |
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
# Pass in the name of the site you wich to create a cert for | |
domain_name = ARGV[0] | |
if domain_name == nil | |
puts "Y U No give me a domain name?" | |
else | |
system "openssl genrsa -out #{domain_name}.key 1024" | |
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'" | |
system "cp #{domain_name}.key #{domain_name}.key.bak" |
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
# Given an application, yield to a block to handle exceptions | |
class ExceptionRaiserApp | |
def initialize(app, &block) | |
@app = app | |
@block = block | |
end | |
def call(env) | |
@app.call(env) | |
rescue => e |