Pattern: Repeated call to memoized subject
Issue: -
Checks for repeated calls to subject missing that it is memoized.
# bad
it do
subject
expect { subject }.to not_change { A.count }
end
it do
expect { subject }.to change { A.count }
expect { subject }.to not_change { A.count }
end
# good
it do
expect { my_method }.to change { A.count }
expect { my_method }.to not_change { A.count }
end
# also good
it do
expect { subject.a }.to change { A.count }
expect { subject.b }.to not_change { A.count }
end