Myron Marston myronmarston

View simplecov_setup.rb
1 2 3 4 5 6 7
original_process = Process.pid
 
SimpleCov.at_exit do
if Process.pid == original_process
SimpleCov.result.format!
end
end
View bundle-standalone-repro.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
 
set -ex
 
mkdir -p /tmp/repro-bundle-standalone-failure
cd /tmp/repro-bundle-standalone-failure
 
bundle env
# Bundler 1.5.2
# Ruby 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.4.0]
View queues.rb
1 2 3 4 5 6 7 8 9 10
➜ 8549841 git:(master) ✗ ruby queues.rb
Popping before put
popped job:
popped job:
popped job:
popped job:
popped job:
popped job:
popped job:
popped job:
View in_sub_process.rb
1 2 3 4 5 6 7 8 9 10
module InSubProcess
if Process.respond_to?(:fork) && !(RUBY_PLATFORM == 'java' && RUBY_VERSION == '1.8.7')
# Useful as a way to isolate a global change to a subprocess.
def in_sub_process
readme, writeme = IO.pipe
 
pid = Process.fork do
exception = nil
begin
yield
View message_specific_error_classifier.rb
1 2 3 4 5 6 7 8 9 10
# Generates a module that can be used in a rescue clause
# in order to rescue errors that match a specific class
# and message. This is useful when there is a generic
# error like `Sequel::Mysql2Error` that we want to only rescue
# some instances of based on the message.
module MessageSpecificErrorClassifier
def self.new(root_error, fragment)
Module.new do
define_singleton_method(:fragment) { fragment }
define_singleton_method(:root_error) { root_error }
View foo.rb
1 2 3 4 5 6 7 8 9 10
class Foo
def call_private_bar
bar
end
 
private
 
def bar
:private_bar
end
View Rakefile
1 2 3 4 5 6 7 8 9 10
begin
require 'rspec/core/rake_task'
rspec_loaded = true
rescue LoadError
rspec_loaded = false
puts "\nThe spec tasks were not defined since rspec could not be loaded.\n\n"
end
 
if rspec_loaded
# define the tasks that depend on RSpec
View gc_signal.rb
1 2 3 4 5 6 7 8 9 10
trap('USR1') do
before_status = File.read("/proc/#{Process.pid}/status")
before_time = Time.now
GC.start
after_time = Time.now
duration_in_ms = ((after_time - before_time) * 1000).to_i
after_status = File.read("/proc/#{Process.pid}/status")
 
log(:error, "Ran GC. Took #{duration_in_ms} ms. Before proc status: #{before_status}. After proc status: #{after_status}")
end
View ruby-1.8.7-build.log
1 2 3 4 5 6 7 8 9 10
➜ ~ ruby-install ruby 1.8
>>> Installing ruby 1.8.7-p374 into /Users/myron/.rubies/ruby-1.8.7-p374 ...
>>> Installing dependencies for ruby 1.8.7-p374 ...
Warning: openssl-1.0.1e already installed
Warning: readline-6.2.4 already installed
Warning: libyaml-0.1.4 already installed
Warning: gdbm-1.10 already installed
Warning: libffi-3.0.13 already installed
>>> Downloading http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p374.tar.bz2 into /Users/myron/src ...
% Total % Received % Xferd Average Speed Time Time Time Current
View why_double.md

TL; DR: "mock" and "stub" were the common terminology when RSpec's API was first created but we've realized that using them to create fake objects causes confusion and that double is a much better term.

I wasn't around when RSpec's original APIs were created, so this is a bit of guess work, but here's my understanding.

When RSpec's mocking API was first created, the two common terms used for what we now commonly call "test doubles" were mocks and

Something went wrong with that request. Please try again.