The assert equal 2 is requrired, since assert_has_calls only check that those calls are among the actual calls... in case the key.store has more  than 2 calls, the assert_has_calls will still pass.