mock_context: Mock context to test tricks

View source: R/11-mock.R

mock_contextR Documentation

Mock context to test tricks

Description

mock_context() does some magic so calls to current_selection() and other functions using context information (i.e. document content, id, path, and selection(s)) will fetch preset data. It is useful to design tests. call unmock

Usage

mock_context(contents = "", id = 1, path = "", selection = NULL)

Arguments

contents

A character vector containing lines of code

id

A number

path

A string

selection

A nested list where elements are named lists of range created by rstudioapi::document_range() and position created by rstudioapi::document_range(). By default contents is fully selected, which should be enough for most tests.

Value

Returns NULL invisibly, Called for side effects.


moodymudskipper/poof documentation built on Dec. 10, 2024, 12:07 a.m.