Skip to content

Instantly share code, notes, and snippets.

View joselo's full-sized avatar

Jose Carrion joselo

View GitHub Profile
@joselo
joselo / test_helper.rb
Created April 13, 2012 03:18 — forked from gnepud/test_helper.rb
MiniTest::Spec with Rails 3.2 setup
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
require 'capybara/rails'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
@joselo
joselo / gist:2373301
Created April 13, 2012 03:08 — forked from cfcosta/gist:2124269
integration test helper for rails with minitest
ENV['RAILS_ENV'] = "test"
unless defined?(Bundler)
require 'bundler/setup'
end
require 'minitest/autorun'
require 'factory_girl'
MiniTest::Unit::TestCase.send(:include, FactoryGirl::Syntax::Methods)
@joselo
joselo / minitest_spec_expectations.md
Created March 22, 2012 19:53 — forked from ordinaryzelig/minitest_spec_expectations.md
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@joselo
joselo / solr_cap.rb
Created March 22, 2012 15:47 — forked from doitian/solr_cap.rb
sunspot solr in capistrano
namespace :deploy do
task :setup_solr_data_dir do
run "mkdir -p #{shared_path}/solr/data"
end
end
namespace :solr do
desc "start solr"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
@joselo
joselo / deploy.rb
Created March 22, 2012 15:44 — forked from brutuscat/deploy.rb
Simple Sunspot Solr Capistrano Tasks
# Simple Start and Stop tasks for your Solr server.
# 1 - Download your Solr from http://www.apache.org/dyn/closer.cgi/lucene/solr/ and extract it somewhere
# 2 - Set the :solr_path with the full path to the Solr "example" dir
#
# NOTES:
# - sunspot_solr gem must be in your Gemfile
# - It will run the "example" Jetty-embed Solr server (start.jar)
# - It will automatically pick your project Solr config from your "project_path/solr" with the Sunspot schema and files.
@joselo
joselo / gist:1942709
Created February 29, 2012 17:25 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@joselo
joselo / new.rb
Created January 5, 2012 21:41 — forked from jferris/new.rb
New FactoryGirl definition syntax
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password "test"
aliased_as :author
end
@joselo
joselo / elements.md
Created November 19, 2011 18:04 — forked from soveran/elements.md
Excerpts from The Elements of Programming Style. The source of this compilation is unknown.

The Elements of Programming Style

The following rules of programming style are excerpted from the book "The Elements of Programming Style" by Kernighan and Plauger, published by McGraw Hill. Here is quote from the book: "To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually find in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules."

@joselo
joselo / Gemfile
Created November 7, 2011 02:12 — forked from mislav/Gemfile
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass'
end
@joselo
joselo / spec_helper.rb
Created September 12, 2011 22:02 — forked from ryanb/spec_helper.rb
Focus on specific specs in RSpec
# add this to your spec helper
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
# and then use the :focus tag in your specs
it "does something awesome", :focus do