Slide 1

Slide 1 text

RSpec: The Bad Parts Caleb Hearth

Slide 2

Slide 2 text

Caleb Hearth

Slide 3

Slide 3 text

Caleb Hearth

Slide 4

Slide 4 text

Caleb Hearth 🛤

Slide 5

Slide 5 text

Caleb Hearth

Slide 6

Slide 6 text

Caleb Hearth Test Double calebhearth.com

Slide 7

Slide 7 text

Caleb Hearth calebhearth.com Test Double dice.camp/@caleb

Slide 8

Slide 8 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double dice.camp/@caleb Caleb Hearth calebhearth.com Test Double RSpec: The Bad Parts

Slide 9

Slide 9 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:player) { Dwarf.new } player Dwarf.new }

Slide 10

Slide 10 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double def player = @player ||= Dwarf.new

Slide 11

Slide 11 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double def player @player ||= Dwarf.new end

Slide 12

Slide 12 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:player) { Dwarf.new }

Slide 13

Slide 13 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:player) { Dwarf.new } let(:party) { [player] }

Slide 14

Slide 14 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:player) { Dwarf.new } let(:party) { [player] } context "An elf" do let(:player) { Elf.new } end

Slide 15

Slide 15 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:player) { Dwarf.new } let(:party) { [player] } subject { player }

Slide 16

Slide 16 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double subject { player }

Slide 17

Slide 17 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double subject(:player) { player } subject { player }

Slide 18

Slide 18 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:subject) { player } subject

Slide 19

Slide 19 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double before do player.quest_for_the_mcguffin end

Slide 20

Slide 20 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double before do player.quest_for_the_mcguffin end

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

General Fixture 🫡

Slide 30

Slide 30 text

General Fixture 🫡

Slide 31

Slide 31 text

General Fixture 🫡

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double avoid(:let)

Slide 36

Slide 36 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double avoid(:let)

Slide 37

Slide 37 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double :let) avoid( )

Slide 38

Slide 38 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double avoid(:subject) avoid( )

Slide 39

Slide 39 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double let(:book) { Book.new }

Slide 40

Slide 40 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double @book = Book.new

Slide 41

Slide 41 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double def book @book ||= Book.new end

Slide 42

Slide 42 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double it "has 10 pages" expect(Book.new.page_count) .to eq 10 end Book.new

Slide 43

Slide 43 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double it "has 10 pages" expect(Book.new.page_count) .to eq 10 end Book.new

Slide 44

Slide 44 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double it "has 10 pages" expect(Book.new.page_count) .to eq 10 end Book.new

Slide 45

Slide 45 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🏜

Slide 46

Slide 46 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double

Slide 47

Slide 47 text

- The Pragmatic Programmer Every piece of knowledge must have a single, unambiguous, authoritative representation within a system “

Slide 48

Slide 48 text

- The Pragmatic Programmer Every piece of knowledge must have a single, unambiguous, authoritative representation within a system “

Slide 49

Slide 49 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🏜

Slide 50

Slide 50 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double subject { described_class.new }

Slide 51

Slide 51 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double subject { Book.new } Book.new

Slide 52

Slide 52 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double Book.new

Slide 53

Slide 53 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double Book.new

Slide 54

Slide 54 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double

Slide 55

Slide 55 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double expect(order).not_to be_sent

Slide 56

Slide 56 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double expect(order.sent?).to eq(false)

Slide 57

Slide 57 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double

Slide 58

Slide 58 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🏜

Slide 59

Slide 59 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🌊

Slide 60

Slide 60 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🌊 🌊

Slide 61

Slide 61 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🌊🌊 🌊

Slide 62

Slide 62 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 🌊

Slide 63

Slide 63 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double 👃

Slide 64

Slide 64 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do subject { account.mute!(target_account, notifications: arg_notifications) } end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 65

Slide 65 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do subject { account.mute!(target_account, notifications: arg_notifications) } end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end spec/models/concerns/account_interactions_spec.rb

Slide 66

Slide 66 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do subject { account.mute!(target_account, notifications: arg_notifications) } end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end spec/models/concerns/account_interactions_spec.rb

Slide 67

Slide 67 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do subject { account.mute!(target_account, notifications: arg_notifications) } end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates Mute, and returns Mute' do expect do expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute, and updates mute.hide_notifications true' do expect do expect(subject).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 68

Slide 68 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'creates Mute, and returns Mute' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates Mute, and returns Mute' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates Mute, and returns Mute' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute without updating mute.hide_notifications' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute without updating mute.hide_notifications' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute, and updates mute.hide_notifications true' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute without updating mute.hide_notifications' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute, and updates mute.hide_notifications true' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 69

Slide 69 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns Mute without updating mute.hide_notifications' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'returns Mute without updating mute.hide_notifications' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end end end

Slide 70

Slide 70 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end

Slide 71

Slide 71 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end

Slide 72

Slide 72 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do mute = account.mute!(target_account, notifications: arg_notifications) expect(mute).to be_kind_of Mute end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end

Slide 73

Slide 73 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'returns Mute, and updates mute.hide_notifications false' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end

Slide 74

Slide 74 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns a Mute' do expect(account.mute!(target_account, notifications: arg_notifications)) .to be_kind_of Mute end it 'creates a Mute' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates a Mute' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates a Mute' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: hide_notifications) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: arg_notifications) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'updates mute.hide_notifications false' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: arg_notifications) end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: arg_notifications) end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 75

Slide 75 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'returns a Mute' do expect(account.mute!(target_account, notifications: arg_notifications)) .to be_kind_of Mute end it 'creates a Mute' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'creates a Mute' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'creates a Mute' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: true) end context 'mute.hide_notifications is true' do let(:hide_notifications) { true } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: arg_notifications) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'updates mute.hide_notifications false' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: arg_notifications) end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do let(:hide_notifications) { false } context 'arg :notifications is nil' do let(:arg_notifications) { nil } it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: arg_notifications) end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: arg_notifications) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 76

Slide 76 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do context 'arg :notifications is nil' do it 'returns a Mute' do expect(account.mute!(target_account, notifications: nil)) .to be_kind_of Mute end it 'creates a Mute' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do it 'creates a Mute' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do it 'creates a Mute' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: true) end context 'mute.hide_notifications is true' do context 'arg :notifications is nil' do it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do it 'updates mute.hide_notifications false' do expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do context 'arg :notifications is nil' do it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 77

Slide 77 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do context 'arg :notifications is nil' do it 'returns a Mute' do expect(account.mute!(target_account, notifications: nil)) .to be_kind_of Mute end it 'creates a Mute' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is false' do it 'creates a Mute' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end end context 'arg :notifications is true' do it 'creates a Mute' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: true) end context 'mute.hide_notifications is true' do context 'arg :notifications is nil' do it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do it 'updates mute.hide_notifications false' do expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end end context 'mute.hide_notifications is false' do context 'arg :notifications is nil' do it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do it 'does not update mute.hide_notifications' do expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do it 'updates mute.hide_notifications true' do expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end end

Slide 78

Slide 78 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(account.mute!(target_account)) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: true) end context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 79

Slide 79 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(account.mute!(target_account)) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: true) end context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 80

Slide 80 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(account.mute!(target_account)) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do before do account.mute_relationships << mute end let(:mute) do Fabricate(:mute, account: account, target_account: target_account, hide_notifications: true) end context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 81

Slide 81 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(account.mute!(target_account)) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 82

Slide 82 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(account.mute!(target_account)) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 83

Slide 83 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(account.mute!(target_account)) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do expect do account.mute!(target_account, notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do expect do account.mute!(target_account, notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do expect do account.mute!(target_account, notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 84

Slide 84 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute does not exist yet' do it 'returns a Mute' do expect(Fabricate(:account).mute!(Fabricate(:account))) .to be_kind_of Mute end it 'creates a Mute when :notifications is nil' do account = Fabricate(:account) expect do account.mute!(Fabricate(:account), notifications: nil) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is false' do account = Fabricate(:account) expect do account.mute!(Fabricate(:account), notifications: false) end.to change { account.mute_relationships.count }.by 1 end it 'creates a Mute when :notifications is true' do account = Fabricate(:account) expect do account.mute!(Fabricate(:account), notifications: true) end.to change { account.mute_relationships.count }.by 1 end end context 'Mute already exists' do context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'mute.hide_notifications is false' do it 'updates mute.hide_notifications true when arg :notifications is nil' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end it 'doesnt update mute.hide_notifications when arg :notifications is false' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.not_to change { mute.reload.hide_notifications? }.from(false) end it 'updates mute.hide_notifications true when arg :notifications is true' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: false account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end

Slide 85

Slide 85 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double describe '#mute!' do end context 'Mute already exists' do context 'mute.hide_notifications is true' do it 'does not update mute.hide_notifications when :notifications is nil' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end it 'updates mute.hide_notifications false when :notifications is false' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: false) end.to change { mute.reload.hide_notifications? }.from(true).to(false) end it 'doesnt update mute.hide_notifications false when :notifications=true' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: true) end.not_to change { mute.reload.hide_notifications? }.from(true) end end

Slide 86

Slide 86 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 87

Slide 87 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 88

Slide 88 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 89

Slide 89 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 90

Slide 90 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 91

Slide 91 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 92

Slide 92 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 93

Slide 93 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_kind_of Mute end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 94

Slide 94 text

Caleb Hearth dice.club/@caleb calebhearth.com Test Double it 'does not update mute.hide_notifications when :notifications is nil' do account = Fabricate(:account) target_account = Fabricate(:account) mute = Fabricate :mute, account: account, target_account: target_account, hide_notifications: true account.mute_relationships << mute expect do account.mute!(target_account, notifications: nil) end.not_to change { mute.reload.hide_notifications? }.from(true) end

Slide 95

Slide 95 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double before(:everything)

Slide 96

Slide 96 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double before(:everything)

Slide 97

Slide 97 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double ✅ Database Cleaner before(:everything)

Slide 98

Slide 98 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double ✅ Database Cleaner ✅ Webmock before(:everything)

Slide 99

Slide 99 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double ✅ Database Cleaner ✅ Webmock ✅ Global things before(:everything)

Slide 100

Slide 100 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double ✅ Database Cleaner ✅ Webmock ✅ Global things ❌ Most things in spec fi les before(:everything)

Slide 101

Slide 101 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double before vs let

Slide 102

Slide 102 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double before vs let +before let

Slide 103

Slide 103 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double shared_examples shared_context behaves_like

Slide 104

Slide 104 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double module DoThingsable end

Slide 105

Slide 105 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double module DoThingsable extend ActiveModel::Concern end Caleb Hearth dice.camp/@caleb calebhearth.com Test Double

Slide 106

Slide 106 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double Caleb Hearth dice.camp/@caleb calebhearth.com Test Double

Slide 107

Slide 107 text

Caleb Hearth dice.camp/@caleb calebhearth.com Test Double

Slide 108

Slide 108 text

Caleb Hearth dice.camp/@caleb calebhearth.com What topics would be helpful to you? link.testdouble.com/rubysurvey

Slide 109

Slide 109 text

Got a puzzler? Request a 1:1 
 virtual pairing 
 session with us! link.testdouble.com/rubypair Caleb Hearth dice.camp/@caleb calebhearth.com