RSpec Matchers: Be careful while testing boolean values
Programming, Technologies, Tips ·While testing methods that return boolean values in ruby (the ones that end in ‘?’), try to avoid following matchers:
or
This is because, ‘be_true’ and ‘be_false’ matchers considers ‘nil’ to be false and anything other than ‘nil’ to be true. When we write methods in ruby which end with question mark (‘?’), intent is that the method will return boolean value. To ensure that our tests will always reflect the intent of code, use following to assert boolean values instead of using ‘be_true’ or ‘be_false’ matchers:
or