From 8d5420283c607cfa6b58397dd43a3497b0cc0aa7 Mon Sep 17 00:00:00 2001 From: Ben Koshy Date: Sat, 6 Feb 2021 09:24:29 +1100 Subject: [PATCH] Clarify readme ***Why this PR?** * To avoid confusion - as in #19. * To simplify and make the documentation clearer, making maintenance easier. --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6cf7324..e9cb8a3 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ Use the following in your test helper to change the test definition permissions PolicyAssertions.config.separator = '__separator__' ``` -## Test Output Results +## How to Make Test Output Results Clear? You may find that the output of certain tests results are confusing. e.g.: @@ -212,7 +212,22 @@ You may find that the output of certain tests results are confusing. e.g.: Expected ProjectPolicy to grant update? on # for # but it didn't ``` -What is `#`? A way to solve this problem is to simply monkey patch the `to_s` method within your tests. +What is `#`? + +### Simple Solution 1: + +* Override `to_s` on the relevant Models. + +```ruby +class User + def to_s + first_name + last_name + end +end +``` +### Solution 2: + +If you want your `to_s` to output different resuts when testing, you could monkey patch the `to_s` method within your tests, leaving production functionality untouched. ```ruby # e.g. test_helper