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
# spec/rails_helper.rb | |
RSpec.configure do |config| | |
if ENV["CI"] | |
config.before(:example, :focus) { raise "Should not commit focused specs" } | |
else | |
config.filter_run focus: true | |
config.run_all_when_everything_filtered = true | |
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
require "test/unit" | |
class CountryMatcherTest < Test::Unit::TestCase | |
def test_valid_case | |
result = CountryMatcher.call("DE") do |match| | |
match.us { "US" } | |
match.de { "DE" } | |
match.gb { "GB" } | |
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
# Little functional quirk to replace a CASE statement, when you first query an object | |
# and call a method to command an action. You can pass a block at the end for an ELSE | |
# statement. | |
# | |
# Usage: | |
# | |
# Func.switch order, | |
# available?: -> { order.submit }, | |
# returned?: -> { order.cancel } | |
# |
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
#!/bin/bash | |
function f() { | |
sleep "$1" | |
echo "$1" | |
} | |
while [ -n "$1" ] | |
do | |
f "$1" & | |
shift | |
done |