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
pt-BR: | |
devise: | |
confirmations: | |
confirmed: 'Sua conta foi confirmada com sucesso.' | |
send_instructions: 'Dentro de minutos, você receberá um e-mail com instruções para a confirmação da sua conta.' | |
send_paranoid_instructions: 'Se o seu endereço de e-mail estiver cadastrado, você receberá uma mensagem com instruções para confirmação da sua conta.' | |
failure: | |
already_authenticated: 'Você já está logado.' | |
inactive: 'Sua conta ainda não foi ativada.' | |
invalid: 'E-mail ou senha inválidos.' |
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 'active_support/all' | |
class RailsConfig | |
class Options < ActiveSupport::OrderedOptions | |
def initialize(value = nil) | |
value.each_pair { |k, v| set_value k, v } if value.is_a?(Hash) | |
end | |
def method_missing(meth, *args) | |
if meth =~ /=$/ |
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 |
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
## 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
# 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
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
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
## 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
# Acceptance spec | |
require "acceptance_helper" | |
feature "Rspec before blocks" do | |
before(:suite) do | |
puts "I'll run just once, before suite" | |
end | |
before(:all) do | |
puts "I'll run 3 times, before all" |
OlderNewer