View rspec_suite_example.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/inline" | |
gemfile do | |
source 'https://rubygems.org' | |
gem "rspec", "~> 3.10" | |
end | |
require "rspec/autorun" | |
RSpec.configure do |config| |
View x_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
class X | |
def self.y | |
YAML.load_file("abc") | |
end | |
end | |
RSpec.describe X do | |
it 'works' do |
View increment_and_decrement.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module IncrementAndDecrement | |
def increment(&block) | |
matcher = change(&block).by(1) | |
RSpec::Matchers::AliasedMatcher.new(matcher, lambda do |desc| | |
desc.gsub("changed", "incremented").gsub("change", "increment") | |
end) | |
end | |
def decrement(&block) | |
matcher = change(&block).by(-1) |
View spec_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Matchers.define_negated_matcher :avoid_outputting, :output | |
RSpec.configure do |config| | |
config.around do |ex| | |
expect(&ex).to avoid_outputting.to_stdout.and avoid_outputting.to_stderr | |
end | |
end |
View my_macros.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyMacros do | |
defmacro my_macro() do | |
module = __CALLER__.module | |
Module.get_attribute(module, :foo) |> IO.inspect(label: "outside quote") | |
quote do | |
Module.get_attribute(unquote(module), :foo) |> IO.inspect(label: "with unquoted module") | |
Module.get_attribute(__MODULE__, :foo) |> IO.inspect(label: "with __MODULE__") | |
end | |
end |
View 0001-add-monitor-statements.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ff210553f1a66db745a32224ff69b57073f953c6 Mon Sep 17 00:00:00 2001 | |
From: Myron Marston <myron.marston@gmail.com> | |
Date: Mon, 27 Feb 2017 15:01:27 -0800 | |
Subject: [PATCH] WIP: add monitor statements. | |
--- | |
lib/mix/lib/mix/dep/converger.ex | 120 ++++++++++++++++++++++----------------- | |
1 file changed, 67 insertions(+), 53 deletions(-) | |
diff --git a/lib/mix/lib/mix/dep/converger.ex b/lib/mix/lib/mix/dep/converger.ex |
View spec_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |rspec| | |
if ENV["CI"] | |
rspec.before(:example, :focus) do | |
raise "Do not commit examples tagged with :focus" | |
end | |
else | |
rspec.filter_run_when_matching :focus | |
end | |
end |
View worker.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias Experimental.GenStage | |
defmodule WorkerPool.Worker do | |
@type subscription_options :: Keyword.t | |
@type producer :: pid | {pid, subscription_options} | |
@doc """ | |
Starts a worker, subscribed to the provided job producers. | |
""" | |
@spec start_link([producer], Keyword.t) :: {:ok, pid} |
View synchronize_death_on_exit.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@doc """ | |
Will ensure the processes with the test does not complete until the process with the | |
provided pid has exited. This is necessary when writing multiple tests that start the | |
same named process. See https://github.com/elixir-lang/elixir/issues/3854 for more info. | |
This accepts either `{:ok, pid}` or just `pid` so that you can use it in a pipeline | |
after a `start_link` call. | |
""" | |
def synchronize_death_on_exit({:ok, pid}) when is_pid(pid), do: synchronize_death_on_exit(pid) | |
def synchronize_death_on_exit(pid) when is_pid(pid) do |
View registry.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Registry do | |
# ... | |
def handle_call({:execute_against_shard, campaign_id, fun}, from, state) do | |
{shard_process, state} = find_or_create_shard(campaign_id, state) | |
ShardProcess.execute_and_reply(shard_process, fun, from) | |
{:noreply, state} | |
end | |
# ... |
NewerOlder