From 34ddc3cc30753435b8b9e74e4f47383340417e9c Mon Sep 17 00:00:00 2001 From: Vsevolod Voloshyn Date: Mon, 18 Jan 2021 11:15:31 +0200 Subject: [PATCH] Fix RSpec slides array changes matcher using --- slides/rspec.markdown | 7 ++++--- slides/rspec_new.markdown | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/slides/rspec.markdown b/slides/rspec.markdown index d2a35f1..615608a 100644 --- a/slides/rspec.markdown +++ b/slides/rspec.markdown @@ -1080,6 +1080,7 @@ RSpec.describe User, 'with some elements' do describe 'with another name' do let(:params) { { name: 'Mark', position: 'PM' } } + it { expect(user.name).to eql('Mark') } end end @@ -1698,7 +1699,7 @@ end ```ruby it 'removes the last element' do - expect { @array.pop }.to change{ @array.size }.by(1) + expect { @array.pop }.to change{ @array.size }.by(-1) end it 'removes the last element' do @@ -1710,11 +1711,11 @@ it 'removes the last element' do end it 'changes size by at least 1' do - expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_least(1) + expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_least(-1) end it 'changes size by at most 2' do - expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_most(2) + expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_most(-2) end ``` diff --git a/slides/rspec_new.markdown b/slides/rspec_new.markdown index 4431dd7..8d117b6 100644 --- a/slides/rspec_new.markdown +++ b/slides/rspec_new.markdown @@ -596,7 +596,7 @@ end ```ruby it 'removes the last element' do - expect { @array.pop }.to change{ @array.size }.by(1) + expect { @array.pop }.to change{ @array.size }.by(-1) end it 'removes the last element' do @@ -608,11 +608,11 @@ it 'removes the last element' do end it 'changes size by at least 1' do - expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_least(1) + expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_least(-1) end it 'changes size by at most 2' do - expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_most(2) + expect { 2.times { @array.pop } }.to change{ @array.size }.by_at_most(-2) end ```