Skip to content

Instantly share code, notes, and snippets.

Lucas Fais lucasfais

  • São Paulo, Brazil
Block or report user

Report or block lucasfais

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lucasfais
lucasfais / operation_test.rb
Created Sep 28, 2008
Usando a macro should_require_attributes do Shoulda
View operation_test.rb
require 'test_helper'
class OperationTest < ActiveSupport::TestCase
should_require_attributes :description, :value
end
@lucasfais
lucasfais / gist:13472
Created Sep 28, 2008
Validando a presenca dos atributos description e value
View gist:13472
class Operation < ActiveRecord::Base
validates_presence_of :description, :value
end
@lucasfais
lucasfais / gist:14754
Created Oct 4, 2008
Avisando o Rails da depenencia com factory_girl
View gist:14754
config.gem "thoughtbot-factory_girl", :lib => "factory_girl", :source => "http://gems.github.com"
View factories.rb
Factory.define :operation_one, :class => Operation do |o|
o.description 'Salario'
o.category 'Proventos'
o.value 5000
end
Factory.define :operation_two, :class => Operation do |o|
o.description 'Gasolina'
o.category 'Transporte'
o.value -200
View operation_test.rb
# ...
should "return its value" do
operation = Factory(:operation_one)
assert_equal 5000, operation.value
end
should "return its category" do
operation = Factory(:operation_two)
assert_equal 'Transporte', operation.category
end
View operation.rb
# ...
def income?
value > 0
end
def expense?
value < 0
end
# ...
View operation_test.rb
require 'test_helper'
class OperationTest < ActiveSupport::TestCase
context "A valid operation" do
setup do
@operation = Factory(:operation_one)
end
View gist:176300
SSHFS mount
1. http://code.google.com/p/macfuse/ (instalar MacFuse)
2. http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS (descompactar e copiar para /usr/local/bin/sshfs; dar permissao de execucao)
3. sshfs root@search_vm:/ /Users/lfais/work/search_vm/ -o allow_other,auto_cache,reconnect,volname=SEARCH_VM,defer_permissions
View gist:419779
=begin
My configuration: ruby 1.8.7-p174, rails 2.3.5 and mongoid 1.9.0.
I need make a tree of nested categories like this:
Category 1
Category 11
Category 12
Category 121
Category 2
You can’t perform that action at this time.