Skip to content

Instantly share code, notes, and snippets.

View lucashungaro's full-sized avatar

Lucas Húngaro lucashungaro

View GitHub Profile
class CardData
def initialize(node)
@card_data = node
end
def name
@card_data.search("name").text
end
def image

"Why You Don't Get Mock Objects" by Gregory Moeck

RubyConf 2011 | 2011-09-29 | Gregory Moeck (@gregmoeck) | Slides

  • Recommended as the best book on mocks: Growing Object-Oriented Software, Guided by Tests by Steve Freeman & Nat Pryce
  • Common arguments against mocks
    • They duplicate implementation
    • They lead to brittle tests
  • Mock objects + procedural programming = bad idea
  • If you're doing traditional Rails development (which tends to follow more of a "procedural", do-this-and-then-do-that style), mock objects probably aren't for you
@lucashungaro
lucashungaro / gist:1924747
Created February 27, 2012 15:38
Some ideas on a small framework. Yet another web framework.
class Lists < App
authenticate { AuthenticationService.authenticate(session) } # just an example, it checks for true or false only
authorize { current_user.role? :admin }, :for => :create, :update # same here
all { List.all } # :get /lists
# the param name should always be class.name.singularize
one { List.find(params[:list]) } # :get /lists/:id
instance { List.new(params[:list]) }
@lucashungaro
lucashungaro / gist:1924445
Created February 27, 2012 15:09 — forked from fnando/gist:1920324
Some ideas on a small framework. Yet another web framework.
class Lists < App
all { List.all } # :get /lists
one { List.find(params[:id]) } # :get /lists/:id
instance { List.new(params[:list]) }
to_update { list.update_attributes(params[:list]) }
to_destroy { list.destroy }
# If you want to set an action for this resource only.
get :search do
@lucashungaro
lucashungaro / irb_require_without_bundler_hack.rb
Created July 21, 2011 04:37 — forked from skojin/irb_require_without_bundler_hack.rb
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_ruby_global_gems_path']}/gems/*/lib")
end
@lucashungaro
lucashungaro / database.yml
Created December 19, 2009 18:47 — forked from jnunemaker/database.yml
mongo initializer to load config from database.yml, authenticate if needed and ensure indexes are created
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
set :application, "myapp"
set :keep_releases, 5
# git options
set :scm, "git"
set :repository, "git://github.com/georgeguimaraes/myapp.git"
set :branch, "master"
set :deploy_via, :remote_cache
# deploy credentials