Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marian13/176e2a98695e81c8f0599d9e3e9ff52d to your computer and use it in GitHub Desktop.
Save marian13/176e2a98695e81c8f0599d9e3e9ff52d to your computer and use it in GitHub Desktop.

Object that raises error on any method call

Useful for mocking in tests.

# An object that raises error on any method call.
Object.new.tap do |object|
object.define_singleton_method(:method_missing) do |*args|
raise 'Error raised from the object that raises error on any method call'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment