This file contains hidden or 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 UniqueUserEmail < ActiveRecord::Migration[5.1] | |
def change | |
enable_extension :citext | |
change_column :users, :email, :citext | |
add_index :users, :email, unique: true | |
end | |
end |
This file contains hidden or 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 "rails_helper" | |
RSpec::Matchers.define_negated_matcher :not_be_present, :be_present | |
RSpec.describe "all matcher" do | |
it "cooperates with negated matchers" do | |
expect([nil, "", " "]).to all(not_be_present) | |
# Whereas this doesn't work: | |
# expect([nil, "", " "]).to_not all(be_present) |
This file contains hidden or 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
def with_mobile_window_size(&block) | |
original_size = page.current_window.size | |
page.current_window.resize_to(320, 480) | |
block.call | |
ensure | |
page.current_window.resize_to(*original_size) | |
end |
This file contains hidden or 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
#!/usr/bin/env sh | |
# Multiple vulnerabilities have been disclosed in RubyGems: | |
# https://www.ruby-lang.org/en/news/2018/02/17/multiple-vulnerabilities-in-rubygems/ | |
# | |
# And again in March 2019: | |
# https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html | |
# | |
# If you're an Rbenv user, here's any easy one-liner to upgrade to a | |
# safe version of Rubygems (2.7.8 / 3.0.3 or later) for each installed Ruby version: |
This file contains hidden or 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
**/* linguist-language=Go |
This file contains hidden or 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 | |
# Save stdout & stderr to individual files: | |
bundle exec rspec > >(tee stdout.log) 2> >(tee stderr.log >&2) | |
# Calculate the percentage: | |
wc -l stderr.log stdout.log \ | |
| ruby -e \ | |
'err, _, total = ARGF.map(&:to_f); puts "#{(err/total*100).round}% error output"' |
This file contains hidden or 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/sh | |
# Checks test files are named "_spec.rb" to match the RSpec globs property | |
# defined in .circleci/config.yml. This will fail the build if there are test | |
# files which don't match the required pattern. | |
# Ignores first-level helper files (e.g. spec_helper.rb) and the spec/support, | |
# spec/factories, spec/shared_examples folders | |
set -eu |
This file contains hidden or 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 | |
gem "rspec" | |
end | |
require "rspec/autorun" | |
RSpec.describe "inline Bundler and autorun RSpec" do | |
it "is convenient for self-contained examples & bug repros" do |
This file contains hidden or 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
# Make Bullet failing tests which opt-in to 'strict' mode | |
# | |
# Based on: | |
# https://github.com/flyerhzm/bullet#run-in-tests | |
# spec/rails_helper.rb or similar | |
RSpec.configure do |config| | |
config.before(:example, :ar_strict) do | |
Bullet.enable = true | |
Bullet.bullet_logger = true |