0

How can I test a method's parameter?

 def create_person child

 end

Above code is my method. It takes a parameter named "child". I try to test this parameter. So, if method doesn't take parameter, test will give me error. I use minitest and Ruby on Rails.

miyamotomusashi
  • 531
  • 7
  • 22

1 Answers1

5

You can use assert_raises to test if an ArgumentError is raised

assert_raises ArgumentError do
  YourClass.create_person
end
Beat Richartz
  • 9,474
  • 1
  • 33
  • 50