- Completely wraps the minitest test lifecycle (
setup
,teardown
, and friends…). This may lead to surprising results. - Supports multiple calls to
around_each
. Each subsequentaround_each
call wraps around the previous one. Is this unintuitive? I don't know. 🤷♂️
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
thing.audio.open do |file| | |
input = file.path | |
output = "#{file.path}.mp3" | |
filename = "#{thing.audio.filename}.mp3" | |
system("ffmpeg", "-i", input, output, exception: true) | |
thing.audio_mp3.attach(io: File.open(output), filename:, content_type: "audio/mpeg") | |
ensure | |
File.delete(output) if File.exist?(output) | |
end |
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
name: lint | |
on: | |
pull_request: | |
push: | |
branches: [ master ] | |
jobs: | |
lint-js: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} |
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
max_redirects = 3 | |
# Follow redirects | |
response = max_redirects.times.lazy.filter_map { | |
puts "Requesting #{url}…" | |
response = Net::HTTP.get_response(URI(url)) | |
case response | |
when Net::HTTPRedirection | |
url = response["location"] | |
nil |
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
github_keys = accounts.map { |account| | |
Net::HTTP.get(URI("https://github.com/#{account}.keys")) | |
.lines(chomp: true) | |
.map { |line| "#{line} @#{account}" } | |
}.flatten |
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
class RawQueryParam < SimpleDelegator | |
def to_query(key) | |
"#{key}=#{value}" | |
end | |
end | |
# … | |
whatever_url(@whatever, host: "bogus.dev", blah: RawQueryParam.new("{test}")) | |
# => "http://bogus.dev/whatever?blah={test}" |
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
class WishlistFlowsTest < ActionDispatch::IntegrationTest | |
setup do | |
@builder = Builder.new | |
end | |
test "can make a wish" do | |
wisher = @builder.users(name: "George Wishington").create! | |
sign_in_as(wisher) | |
assert_changes "Wish.count" do |
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 Seeders | |
class Base | |
def seed!(builder, findable_attributes, unstable_attributes = {}) | |
builder.find_or_create_by!(findable_attributes) do |config| | |
config.assign_attributes(unstable_attributes) | |
end | |
end | |
end | |
class Builder |
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
1Password 7.app | |
Alacritty.app | |
App Store.app | |
Atom.app | |
Audacity.app | |
Automator.app | |
Basecamp 3.app | |
Be Focused Pro.app | |
Be Focused.app | |
Beaker Browser.app |
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
if Gem::Version.new("2.6") <= Gem::Version.new(RUBY_VERSION) | |
def compose(*funcs) | |
funcs.map(&:to_proc).reduce(:<<) | |
end | |
else | |
def compose(*funcs) | |
funcs.map(&:to_proc).reduce { |f, g| ->(*x) { f.call(g.call(*x)) } } | |
end | |
end |
NewerOlder