From 5a7794debae70d894fe776efbce80f9ac5d6683c Mon Sep 17 00:00:00 2001 From: Bob Rudis Date: Tue, 21 Feb 2017 14:09:40 -0500 Subject: [PATCH] basic pkg tests --- NEWS.md | 4 ++++ R/docker-splash.r | 6 +++--- R/render-har.r | 2 +- R/splashr-package.R | 2 +- man/render_har.Rd | 2 +- man/splashr.Rd | 2 +- man/start_splash.Rd | 4 ++-- man/stop_splash.Rd | 2 +- tests/testthat/test-splash.R | 16 +++++++++++++++- 9 files changed, 29 insertions(+), 11 deletions(-) diff --git a/NEWS.md b/NEWS.md index bec1a40..6812531 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ 0.3.0 +* added basic pkg tests +* added mini-DSL to avoid needing to write lua scripts for some common operations +* added many tests for many types of objects +* added HAR support * added `as_req()` * added `as_request()` diff --git a/R/docker-splash.r b/R/docker-splash.r index 9eb702b..c1b0d5c 100644 --- a/R/docker-splash.r +++ b/R/docker-splash.r @@ -18,7 +18,7 @@ install_splash <- function(host = harbor::localhost) { #' If using this in an automation context, you should consider adding a #' `Sys.sleep(3)` (or higher) after starting the docker container. #' -#' @param host Docker host; defauolts to `localhost` +#' @param host Docker host; defaults to `localhost` #' @param add_tempdir This is `FALSE` initially since you could try to run #' the splash image on a remote system. It has to be a local one for this to work. #' If `TRUE` then a local temporary directory (made with [tempdir]()) @@ -26,7 +26,7 @@ install_splash <- function(host = harbor::localhost) { #' ensure the necessary system temp dirs are accessible as a mounts. For #' macOS this means adding `/private` to said Docker config. #' @note you need Docker running on your system and have pulled the container with -#' [install_spash] for this to work. You should save the resultant `host` +#' [install_splash] for this to work. You should save the resultant `host` #' object for use in [stop_splash]. #' @return `harbor` `container` object #' @export @@ -57,7 +57,7 @@ start_splash <- function(host = harbor::localhost, add_tempdir=FALSE) { #' #' @param splash_container Docker `container` object created by [start_splash] #' @note you need Docker running on your system and have pulled the container with -#' [install_spash] and started the Splash container with [start_splash] for this +#' [install_splash] and started the Splash container with [start_splash] for this #' to work. You will need the `container` object from [start_splash] for this to work. #' @export #' @examples \dontrun{ diff --git a/R/render-har.r b/R/render-har.r index a72f86c..7118938 100644 --- a/R/render-har.r +++ b/R/render-har.r @@ -1,7 +1,7 @@ #' Return information about Splash interaction with a website in HAR format. #' #' It includes information about requests made, responses received, timings, headers, etc and -#' is incredibly detailed, full of information on every componenent loaded. +#' is incredibly detailed, full of information on every component loaded. #' #' @md #' @param response_body When `TRUE`, response content is included in the HAR records diff --git a/R/splashr-package.R b/R/splashr-package.R index 740ded3..468136b 100644 --- a/R/splashr-package.R +++ b/R/splashr-package.R @@ -3,7 +3,7 @@ #' 'Splash' is a javascript rendering service. #' It’s a lightweight web browser with an 'HTTP' API, implemented in Python using #' 'Twisted'and 'QT' and provides some of the core functionality of the 'RSelenium' or -#' 'seleniumPipes'R pacakges but with a Java-free footprint. The (twisted) 'QT' reactor is +#' 'seleniumPipes'R packages but with a Java-free footprint. The (twisted) 'QT' reactor is #' used to make the sever fully asynchronous allowing to take advantage of 'webkit' #' concurrency via QT main loop. Some of Splash features include the ability to process #' multiple webpages in parallel; retrieving HTML results and/or take screenshots; diff --git a/man/render_har.Rd b/man/render_har.Rd index 8554402..c995d26 100644 --- a/man/render_har.Rd +++ b/man/render_har.Rd @@ -58,7 +58,7 @@ a \code{HARtools} \code{har} object } \description{ It includes information about requests made, responses received, timings, headers, etc and -is incredibly detailed, full of information on every componenent loaded. +is incredibly detailed, full of information on every component loaded. } \references{ \href{http://splash.readthedocs.io/en/stable/index.html}{Splash docs} diff --git a/man/splashr.Rd b/man/splashr.Rd index e7f04e1..220bd31 100644 --- a/man/splashr.Rd +++ b/man/splashr.Rd @@ -9,7 +9,7 @@ 'Splash' \url{https://github.com/scrapinghub/splash} is a javascript rendering service. It’s a lightweight web browser with an 'HTTP' API, implemented in Python using 'Twisted'and 'QT' and provides some of the core functionality of the 'RSelenium' or -'seleniumPipes'R pacakges but with a Java-free footprint. The (twisted) 'QT' reactor is +'seleniumPipes'R packages but with a Java-free footprint. The (twisted) 'QT' reactor is used to make the sever fully asynchronous allowing to take advantage of 'webkit' concurrency via QT main loop. Some of Splash features include the ability to process multiple webpages in parallel; retrieving HTML results and/or take screenshots; diff --git a/man/start_splash.Rd b/man/start_splash.Rd index d345572..17e2ad6 100644 --- a/man/start_splash.Rd +++ b/man/start_splash.Rd @@ -7,7 +7,7 @@ start_splash(host = harbor::localhost, add_tempdir = FALSE) } \arguments{ -\item{host}{Docker host; defauolts to `localhost`} +\item{host}{Docker host; defaults to `localhost`} \item{add_tempdir}{This is `FALSE` initially since you could try to run the splash image on a remote system. It has to be a local one for this to work. @@ -25,7 +25,7 @@ If using this in an automation context, you should consider adding a } \note{ you need Docker running on your system and have pulled the container with - [install_spash] for this to work. You should save the resultant `host` + [install_splash] for this to work. You should save the resultant `host` object for use in [stop_splash]. } \examples{ diff --git a/man/stop_splash.Rd b/man/stop_splash.Rd index 8f08062..9142686 100644 --- a/man/stop_splash.Rd +++ b/man/stop_splash.Rd @@ -14,7 +14,7 @@ Stop a running a Splash server Docker container } \note{ you need Docker running on your system and have pulled the container with - [install_spash] and started the Splash container with [start_splash] for this + [install_splash] and started the Splash container with [start_splash] for this to work. You will need the `container` object from [start_splash] for this to work. } \examples{ diff --git a/tests/testthat/test-splash.R b/tests/testthat/test-splash.R index ab6f62f..42a1779 100644 --- a/tests/testthat/test-splash.R +++ b/tests/testthat/test-splash.R @@ -1,6 +1,20 @@ context("basic functionality") test_that("we can do something", { - #expect_that(some_function(), is_a("data.frame")) + spact <- splash_active() + + expect_that(spact, equals(TRUE)) + + if (spact) { + + expect_that(length(splash_debug()), equals(7)) + expect_that(length(splash_version()), equals(9)) + expect_that(render_json(url = "https://httpbin.org/get"), is_a("splash_json")) + expect_that(render_png(url = "https://httpbin.org/get"), is_a("magick-image")) + expect_that(render_png(url = "https://httpbin.org/get"), is_a("magick-image")) + expect_that(render_html(url = "https://httpbin.org/get"), is_a("xml_document")) + expect_that(render_har(url = "https://httpbin.org/get"), is_a("har")) + + } })