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
## rake command | |
RAILS_ENV=test DISPLAY=:2.0 rake db:migrate spec:acceptance | |
## init.d | |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: xvfb |
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
#!/bin/bash | |
APP_NAME="your-app-name-goes-here" | |
APP_PATH=/home/deploy/${APP_NAME} | |
# Production environment | |
export RAILS_ENV="production" | |
# This loads RVM into a shell session. Uncomment if you're using RVM system wide. | |
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm" |
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 SimpleForm | |
class FormBuilder < ActionView::Helpers::FormBuilder | |
# You can just override the default submit button and add the functionality. | |
# | |
# Simple usage: | |
# f.button :submit 'Send!', :cancel_link => root_path | |
# | |
def submit(*args) | |
cancel_link = args.last.is_a?(Hash) && args.last.delete(:cancel_link) | |
submit_button = super |
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 'sqlite3' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', :database => ':memory:' | |
) | |
ActiveRecord::Schema.define(:version => 0) do | |
create_table :users, :force => true do |t| |
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
# Re-register selenium driver to be able to pass in the profile option, overriding the user agent. | |
Capybara.register_driver :selenium do |app| | |
require 'selenium/webdriver' | |
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile['general.useragent.override'] = 'FooBar' | |
Capybara::Driver::Selenium.new(app, :profile => profile) | |
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
# Rack-test | |
p find("#lst-servicos-proximos li:eq(1)").text | |
"\n \n LINCES LINCES BLUMENAURUA MARECHAL DEODORO, , 397, BLUMENAU, SC(47) 3035-4455\n \n 63,28 km\n \n \n \n \n | |
p find("#lst-servicos-proximos li:eq(1)").native.class | |
Nokogiri::XML::Element | |
# Selenium | |
p find("#lst-servicos-proximos li:eq(1)").text |
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
## Original | |
def reverse_sql_order(order_query) | |
order_query.join(', ').split(',').collect { |s| | |
if s.match(/\s(asc|ASC)$/) | |
s.gsub(/\s(asc|ASC)$/, ' DESC') | |
elsif s.match(/\s(desc|DESC)$/) | |
s.gsub(/\s(desc|DESC)$/, ' ASC') | |
else | |
s + ' DESC' | |
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
## Simple config class - testing purposes =) | |
FooConfig = Class.new do | |
def initialize(config_file, env) | |
@config = YAML.load_file(config_file)[env] | |
end | |
def method_missing(method, *args) | |
@config.send(:[], method.to_s, *args) | |
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
class Test | |
def self.public_method | |
"Hello from public" | |
end | |
protected | |
def self.protected_method | |
"Hello from 'supposted' protected method" | |
end |
NewerOlder