Skip to content

Instantly share code, notes, and snippets.

View anildigital's full-sized avatar
:octocat:

Anil Wadghule anildigital

:octocat:
View GitHub Profile

Notes on teaching both test/unit and RSpec to new Ruby developers

@tenderlove asked "Is it good to teach RSpec (vs t/u) to people who are totally new to Ruby?" I have experience suggesting that it is a good thing; after a short back and forth, it seemed useful to write it up in detail.

Background

This goes back several years, to when I was the primary Ruby/Rails trainer for Relevance from 2006-2009. I'm guessing that worked out to probably 6-8 classes a year during those years. Since then, RSpec has changed a fair amount (with the addition of expect) and test/unit has changed radically (it has an entirely new implementation, minitest, that avoids some of the inconsistencies that made test/unit a bit confusing during the time I'm writing about here).

I started out as an RSpec skeptic. I've never been afraid of what a lot of people denigrate as "magic" in Ruby libraries … to me, if you take the trouble to understand it, that stuff's just pr

@anildigital
anildigital / gist:9069004
Created February 18, 2014 11:14
Running graphite using UDP Port
$ docker run -d -p 8181:80 -p 8125:8125/udp jayofdoom/trusty-graphite-standalone
@anildigital
anildigital / gist:8253474
Created January 4, 2014 09:34
Cleanup exited docker containers
sudo docker ps -a | grep Exit | awk '{print $1}' | sudo xargs docker rm
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh

ert

(ert-deftest foo ()
  (assert nil))

Now: M-x ert RET foo RET

apropos

Emacs makes discovery easier.

require 'json'
require 'date'
# Embedders
def scalar
lambda { |x| x }
end
def date
@anildigital
anildigital / config.ru
Created July 22, 2013 08:29
Rackup script for streaming image
require 'rack/stream'
use Rack::Stream
run lambda {|env|
stream = env['rack.stream']
stream.after_open do
times = 0
open("./moi_munnar_up.jpg", "rb") {|f|
Anil-Wadghules-MacBook-Pro:~ anil$ redis-server
[3933] 11 Jul 20:04:52.382 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[3933] 11 Jul 20:04:52.384 * Max number of open files set to 10032
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.14 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 3933
@anildigital
anildigital / adapter.rb
Last active December 19, 2015 10:19
I gave talk on 'Design Patterns in Ruby' at Pune Ruby Users Group meetup at ThoughtWorks. Here are the slides https://speakerdeck.com/anildigital/design-patterns-in-ruby And below are the code snippets which I used to demo.
# Example from http://www.takadevelop.com/2013/05/03/adapter-pattern-in-ruby/
# Adapter Design Pattern
# Abstract Duck
class Duck
def quack
end
def fly
end
@anildigital
anildigital / config
Created November 23, 2012 09:59
Add to your SSH configuration in .ssh/config
Host 35
ProxyCommand ssh near_ip nc distant_ip 22
User admin