Skip to content

Instantly share code, notes, and snippets.

View chriskottom's full-sized avatar
😁
Hustlin'

Chris Kottom chriskottom

😁
Hustlin'
View GitHub Profile
@chriskottom
chriskottom / estimate.rb
Last active November 8, 2019 07:05
Estimates
class Estimate < ApplicationRecord
def accept!
# update db
end
def reject!
# update db
end
...
@chriskottom
chriskottom / Gemfile
Created April 18, 2018 05:29
Using the HtmlReport from Minitest::Reporters
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'rake'
gem 'minitest'
gem 'minitest-reporters'
@chriskottom
chriskottom / .gitignore
Created November 2, 2017 17:30
Current Rails project .gitignore
# Editor temporary files
#
*~
\#*\#
.\#*
*.swp
*.swo
*.sublime-project
*.sublime-workspace
@chriskottom
chriskottom / Gemfile
Created September 19, 2017 13:19
Rails Testing Stack Setup
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
@chriskottom
chriskottom / Rakefile
Created September 12, 2017 08:41
Rake::TestTask with verbose output
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs = %w(lib test)
t.pattern = 'test/**/*_test.rb'
t.options = '-v'
end
@chriskottom
chriskottom / solver.rb
Last active November 21, 2015 06:50
Einstein's Riddle Solver
# EINSTEIN'S RIDDLE
#
# There are five houses in five different colours in a row. In each house lives
# a person with a different nationality. The five owners drink a certain type of
# beverage, smoke a certain brand of cigar and keep a certain pet.
#
# No owners have the same pet, smoke the same brand of cigar, or drink the same
# beverage.
#
# Other facts:
require "minitest/autorun"
class MinitestMockTest < Minitest::Test
def test_method_called_more_times_than_expected
mock = Minitest::Mock.new
3.times { mock.expect :some_method, true }
assert mock.some_method # OK
assert mock.some_method # OK
assert mock.some_method # still OK
@chriskottom
chriskottom / Minitest::Benchmark example
Last active September 1, 2017 04:22
Minitest::Benchmark example
Sample code that shows how to use Minitest::Benchmark in a semi-realistic way
@chriskottom
chriskottom / .gitignore
Last active December 24, 2015 05:29
Rails 4 application setup (MiniTest, HAML, ...)
# Emacs temporary files
*~
\#*\#
# Bundler artifacts
.bundle
vendor/bundle
# Database configuration, files
config/database.yml
@chriskottom
chriskottom / deploy.rb
Created September 10, 2013 09:23
A simplified Capistrano recipe for deployment of static websites from a local directory
set :application, 'Example' # the name of your app
set :location, 'example.com' # server address
set :user, 'deploy' # remote user (unprivileged deployment user)
set :group, 'www-data' # remote group (should be the group your web server runs as)
set :use_sudo, false
set :scm, 'none'
set :deploy_via, :copy
set :repository, '.'
set :deploy_to, '/var/www/example'