Skip to content

Instantly share code, notes, and snippets.

Augusts Bautra Epigene

View GitHub Profile
@Epigene
Epigene / bundler.config
Last active Dec 24, 2019
Make bundler always use some pg_config
View bundler.config
# single install
gem install pg -v 1.1.4 -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/12/bin/pg_config
# permanent config, troublesome
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.6/bin/pg_config
View command+d_to_f11.json
{
"title": "Command+D show desktop",
"rules": [
{
"description": "Command+D show desktop",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "d",
@Epigene
Epigene / bench_data.csv
Created Oct 14, 2017
Raw data for setup strategy comparison
View bench_data.csv
file line_number group time
./spec/setup_benchmark.rb 9 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithNew 0.198
./spec/setup_benchmark.rb 17 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithInstanceDouble 0.173
./spec/setup_benchmark.rb 25 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithFactoryGirlBuildStubbed 0.396
./spec/setup_benchmark.rb 33 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithFactoryGirlBuild 0.916
./spec/setup_benchmark.rb 41 SetupBenchmark::NewVSAllOthersWhenTestingBookVampireTitle::WhenSettingUpWithFactoryGirlCreate 1.155
./spec/setup_benchmark.rb 55 SetupBenchmark::InstanceDoubleVSFactoryGirlBuildStubbedFactoryGirlBuildAndFactoryGirlCreate::WhenSettingUpWithInstanceDouble 0.443
@Epigene
Epigene / book.rb
Created Oct 14, 2017
complete mock
View book.rb
after_save :do_something
private
def do_something
ApplicationRecord.class
end
@Epigene
Epigene / bout4.rb
Created Oct 14, 2017
Build VS create
View bout4.rb
describe "FactoryGirl.build VS FactoryGirl.create" do
subject { book.save! }
bout4_number_of = 200
context "when setting up with FactoryGirl.build" do
let(:book) { build(:book) }
bout4_number_of.times do
it "triggers ApplicationRecord.class in callback" do
@Epigene
Epigene / book.rb
Created Oct 14, 2017
Matching author and publisher names?
View book.rb
def with_characteristics?(characteristics_hash)
author.name == characteristics_hash[:author_name] &&
publisher.name == characteristics_hash[:publisher_name]
end
@Epigene
Epigene / bout3.rb
Created Oct 14, 2017
FC.build_stubbed vs other FC strategies
View bout3.rb
describe "FactoryGirl.build_stubbed VS [FactoryGirl.build, FactoryGirl.create]" do
subject { book.with_characteristics?(options) }
let(:options) { {author_name: book.author.name, publisher_name: book.publisher.name} }
bout3_number_of = 200
context "when setting up with FactoryGirl.build_stubbed" do
let(:book) { build_stubbed(:book) }
@Epigene
Epigene / bout2.rb
Created Oct 14, 2017
#build_stubbed vs FactoryGirl strategies
View bout2.rb
describe "#instance_double VS FactoryGirl.build_stubbed, FactoryGirl.build, and FactoryGirl.create" do
subject { book.by_bce_autor? }
bout2_number_of = 200
context "when setting up with #instance_double" do
let(:book) { build_stubbed(:book) }
let(:author) { instance_double("Author", bce?: true) }
before { allow(book).to receive(:author).and_return(author) }
@Epigene
Epigene / book.rb
Created Oct 14, 2017
Ancient author?
View book.rb
def by_bce_autor?
author.bce?
end
@Epigene
Epigene / bout1.rb
Created Oct 14, 2017
#new VS all other setup strategies
View bout1.rb
describe "#new VS all others when testing Book#vampire_title?" do
subject { book.vampire_title? }
bout1_number_of = 200
context "when setting up with #new" do
bout1_number_of.times do
let(:book) { Book.new(title: "Vampire Literature, a Historical Perspective") }
it { is_expected.to eq(true) }
You can’t perform that action at this time.