Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,30 @@ 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.:

```shell
Expected ProjectPolicy to grant update? on #<Project:0x00007f7d04514ef0> for #<User:0x00007f7d045001a8> but it didn't
```

What is `#<User:0x00007f7d045001a8>`? A way to solve this problem is to simply monkey patch the `to_s` method within your tests.
What is `#<User:0x00007f7d045001a8>`?

### 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
Expand Down