ruby - How to test that invalid arguments raise an ArgumentError exception using RSpec? -


I am writing a rubious which can raise an ArgumentError if arguments are the same method invalid How can I write an exam for this using RSPC?

The examples below look like an implementation in my mind. I bar method is expected to have a single boolean argument (: baz ), which Type check is to ensure that it is actually a boolean:

  module Foo def self.bar (options = {}) baz = options.fetch (: baz, true) validate_arguments (Hawk) end personal def self.validate_arguments (hawk) increase (ArgumentError, ": baz should be a boolean") until valid_baz? (Baz) end df self.valid_baz? (Baz) baz.is_a? (TrueClass) || Baz.is_a? (FalseClass) End of the End  

I use anything that poison Posted:

  It expects logic for arguments that are not boolean "{Foo.validate_arguments (zero)}. At the end of Raise_error (ArgumentError)  

no other nickname (RSPEC 1.3) is required.


Comments