package_stub: Stub a function in a package by replacing it with something...

Description Usage Arguments Examples

View source: R/stub.R

Description

Stubbing a function in a package can only be done in the context of some expression (a block of code). Otherwise, dangerous things could happen! (We are actually replacing the function in the package's namespace.)

Usage

1
package_stub(package_name, function_name, stubbed_value, expr)

Arguments

package_name

character. The name of the package to look in.

function_name

character. The name of the function to stub.

stubbed_value

function. The function to temporarily replace this function with.

expr

expression. An expression to evaluate with the stubbed changes. The stubbing will be reverted after this expression is executed.

Examples

1
package_stub("methods", "new", function(...) 'test', stopifnot(new('example') == 'test')) 

robertzk/testthatsomemore documentation built on Aug. 15, 2017, 7:45 a.m.