Skip to content

Instantly share code, notes, and snippets.

View avegancafe's full-sized avatar

Kyle Holzinger avegancafe

View GitHub Profile
╔║
┌─╫╫─┐
│ ├┐
│♠ ♣ └│
│ └ └┘
│⌐-¬ │
│ │
│ │
└──┘ │
did:3:bafyreihkrxaxtxcan3upovrglthgzyouv27ffnrqgmc7xcv33zph5lom7a
@avegancafe
avegancafe / space_authority_avoid_order_flakes_spec.rb
Created May 17, 2020 19:29
Examples for RSpec Formatting Blog Post - space_authority_avoid_order_flakes_spec.rb
describe SpaceAuthority do
let!(:user) { create(:user) }
let!(:middle_space) { create(:space, unit: 'first space', sort_order: 2) }
let!(:last_space) { create(:space, unit: 'middle space', sort_order: 3) }
let!(:first_space) { create(:space, unit: 'last space', sort_order: 1) }
subject { described_class.new(user).spaces(order: :sort_order) }
it 'sorts spaces' do
expect(subject.map(&:unit)).to eq([
first_space,
@avegancafe
avegancafe / space_authority_mutually_ordered_creation_spec.rb
Created May 17, 2020 18:48
Examples for RSpec Formatting Blog Post - space_authority_mutually_ordered_creation_spec.rb
describe SpaceAuthority do
let!(:user) { create(:user) }
let!(:first_space) { create(:space, unit: 'first space', sort_order: 0) }
let!(:middle_space) { create(:space, unit: 'middle space', sort_order: 0) }
let!(:last_space) { create(:space, unit: 'last space', sort_order: 0) }
subject { described_class.new(user).spaces(order: :sort_order) }
it 'sorts spaces' do
expect(subject.map(&:unit)).to eq([
first_space,
@avegancafe
avegancafe / space_authority_a_few_eager_objects_spec.rb
Last active May 17, 2020 18:44
Examples for RSpec Formatting Blog Post - space_authority_a_few_eager_objects_spec.rb
describe SpaceAuthority do
let!(:property) do
# this property is needed in all tests
end
context 'property tests' do
# no extra objects needed here
end
# floor and space tests utilize top-level property, but instantiate
@avegancafe
avegancafe / space_authority_so_many_objects_spec.rb
Last active May 17, 2020 18:39
Examples for RSpec Formatting Blog Post - space_authority_so_many_objects_spec.rb
describe SpaceAuthority do
let(:property) do
# generic property that might be needed in a couple of places
end
let(:floor) do
# generic floor that might be needed in a couple of places
end
let(:space) do
# generic space that might be needed in a couple of places
end
@avegancafe
avegancafe / space_authority_lazy_load_evaluations_spec.rb
Last active May 17, 2020 18:36
Examples for RSpec Formatting Blog Post - space_authority_lazy_load_evaluations_spec.rb
describe SpaceAuthority do
describe '#authorized_spaces' do
let(:user) { create(:user) }
let(:authorized_space_through_property) { create(:space, unit: 'authorized space through property', ...) }
let(:authorized_space_directly) { create(:space, unit: 'authorized space directly', ...) }
let(:unauthorized_space) { create(:space, unit: 'unauthorized space', ...) }
subject { described_class.new(user).authorized_spaces }
it 'only lists authorized spaces' do
expect(subject.map(&:unit)).to match_array([
@avegancafe
avegancafe / space_authority_eager_load_evaluations_spec.rb
Last active May 17, 2020 18:36
Examples for RSpec Formatting Blog Post - space_authority_eager_load_evaluations_spec.rb
describe SpaceAuthority do
describe '#authorized_spaces' do
let(:user) { create(:user) }
let!(:authorized_space_through_property) { create(:space, unit: 'authorized space through property', ...) }
let!(:authorized_space_directly) { create(:space, unit: 'authorized space directly', ...) }
let!(:unauthorized_space) { create(:space, unit: 'unauthorized space', ...) }
subject { described_class.new(user).authorized_spaces }
it 'only lists authorized spaces' do
expect(subject.map(&:unit)).to match_array([
@avegancafe
avegancafe / space_authority_array_name_expectations_spec.rb
Last active May 18, 2020 16:01
Examples for RSpec Formatting Blog Post - space_authority_array_name_expectations_spec.rb
describe SpaceAuthority do
describe '#authorized_spaces' do
let!(:authorized_space_through_property) { create(:space, suite: 'authorized space through property', ...) }
let!(:authorized_space_directly) { create(:space, suite: 'authorized space directly', ...) }
let!(:unauthorized_space) { create(:space, suite: 'unauthorized space', ...) }
subject { described_class.new(user).authorized_spaces }
it 'only lists authorized spaces' do
expect(subject.map(&:suite)).to match_array([
authorized_space_through_property,
@avegancafe
avegancafe / space_authority_array_id_expectations_spec.rb
Created May 5, 2020 18:51
Examples for RSpec Formatting Blog Post - space_authority_array_id_expectations_spec.rb
describe SpaceAuthority do
describe '#authorized_spaces' do
let!(:authorized_space_through_property) { create(:space, ...) }
let!(:authorized_space_directly) { create(:space, ...) }
let!(:unauthorized_space) { create(:space, ...) }
subject { described_class.new(user).authorized_spaces }
it 'only lists authorized spaces' do
expect(subject.map(&:id).to match_array([
authorized_space_through_property.id,