README.md

crunchdev

Build Status codecov cran

The crunchdev package offers a number of convenience functions and RStudio addins to make developing crunch packages quicker and faster.

Highlights of CrunchDev include: addins for quickly and easily specifying host, test type (unit vs integration), and file filters These make it quick and easy to run tests on specific files which speeds up how quickly you can see if those test pass or fail, and can get back into the code. It handles all of the logic for setting up hosts and authentication for integration tests so you don't have to change any configurations or options to run them. Test are run in a terminal within RStudio so they won't block any other processes or coding you might want to do. easily change backends interactively with setupCrunch() There are a number of backends that are useful to use in the process of developing Crunch packages. This function lets you change which backend you are configured to connect to (eg changes the crunch.email, crunch.pw, and crunch.api options). No more fumbling with changing options or reloading R.

Installing

The pre-release version of the package can be pulled from GitHub using the devtools package:

# install.packages("devtools")
devtools::install_github("Crunch-io/crunchdev")

Configuration

Before using crunchdev there are a few options that should be added to your ~/.Rprofile:

  1. host name url maps --- there are two groups: user.hosts and test.hosts the first uses user authentication, and the second uses test user authentication. Each list can have any number of hostnames and urls.
crunchdev.user.hosts=c("stableapp" = "https://stableapp.crunch.io/api/"),
crunchdev.test.hosts=c(
       "local" = "http://local.crunch.io/api/",
       "testing server" = "https://testing.crunch.io/api/")
  1. authentication maps --- again, there are two groups: user.auth and test.auth the first is used for all hosts in crunchdev.user.hosts, and the second is used for all hosts in crunchdev.test.hosts. Each one should only contain one email and password.
crunchdev.user.auth=c("email" = "magic.user@crunch.io",
                      "pw" = "t0pSecretP@ssw0rD"),
crunchdev.test.auth=c("email" = "magic.testuser@crunch.io",
                      "pw" = "t0pSecretP@ssw0rD")

Example additions to an .Rprofile

options(
    crunchdev.user.auth=c("email" = "developer@crunch.io",
    "pw" = "super_secre7_passw0rd"),
    crunchdev.test.auth=c("email" = "tester@crunch.io",
    "pw" = "passw0rd_wh1ch_1s_super_secre7"),
    crunchdev.user.hosts=c("aleph" = "https://aleph.crunch.io/api/"),
    crunchdev.test.hosts=c(
           "bet" = "https://bet.crunch.io/api/",
           "gimmel" = "https://gimmel.crunch.io/api/")
)

Addins

RStudio allows keyboard shortcuts to be bound to addins. The addins provided by crunchdev are designed to make iteration and test running quick and easy. Note: currently launching a terminal from RStudio requires installing rstudioapi from feature/terminal and requires RStudio version >= 1.1.331.

For developers

The repository includes a Makefile to facilitate some common tasks.

Running tests

$ make test. Requires the testthat package. You can also specify a specific test file or files to run by adding a "file=" argument, like $ make test file=logging. test_package will do a regular-expression pattern match within the file names. See its documentation in the testthat package.

Updating documentation

$ make doc. Requires the roxygen2 package.



Crunch-io/crunchdev documentation built on Nov. 26, 2020, 11:27 p.m.