Jon Schneider
Jon Schneider

Reputation: 26973

Rails Minitest: "false is not a symbol or a string" when using assert_predicate

In a rails unit test using Minitest, with the following code:

def test_notification
  # ("Arrange" stuff here...)

  get root_path

  assert_predicate flash, blank?
end

When run, the assert_predicate line causes the error:

Minitest::UnexpectedError: TypeError: false is not a symbol nor a string

What's going on here?

Upvotes: 0

Views: 278

Answers (1)

Jon Schneider
Jon Schneider

Reputation: 26973

The problem is that blank? needs to be a symbol -- it's missing the leading : in the snippet above. The corrected code:

def test_notification
  # ("Arrange" stuff here...)

  get root_path

  assert_predicate flash, :blank?
end

Upvotes: 1

Related Questions