Browse Source

better tests. trying a Docker Travis config

master
boB Rudis 3 years ago
parent
commit
d63a0c43d7
5 changed files with 49 additions and 24 deletions
  1. +19
    -5
      .travis.yml
  2. +1
    -0
      README.Rmd
  3. +15
    -13
      README.md
  4. BIN
      img/cap.png
  5. +14
    -6
      tests/testthat/test-splash.R

+ 19
- 5
.travis.yml View File

@@ -1,19 +1,33 @@
language: r

warnings_are_errors: true

cache: packages

sudo: required

services:
- docker

before_install:
- docker pull hrbrmstr/splashttpd
- docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 hrbrmstr/splashttpd
- docker ps -a

r:
- oldrel
- release
- devel

apt_packages:
- libv8-dev
- xclip
addons:
apt:
packages:
- xclip
- libv8-dev

env:
global:
- CRAN: http://cran.rstudio.com
- DISPLAY=""
- DISPLAY=:99.0

notifications:
email:


+ 1
- 0
README.Rmd View File

@@ -1,6 +1,7 @@
---
output: rmarkdown::github_document
---
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/splashr.svg?branch=master)](https://travis-ci.org/hrbrmstr/splashr)

`splashr` : Tools to Work with the 'Splash' JavaScript Rendering Service



+ 15
- 13
README.md View File

@@ -1,4 +1,6 @@

[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/splashr.svg?branch=master)](https://travis-ci.org/hrbrmstr/splashr)

`splashr` : Tools to Work with the 'Splash' JavaScript Rendering Service

TL;DR: This package works with Splash rendering servers which are really just a REST API & `lua` scripting interface to a QT browser. It's an alternative to the Selenium ecosystem which was really engineered for application testing & validation.
@@ -146,13 +148,13 @@ splash_debug()
## List of 7
## $ active : list()
## $ argcache: int 0
## $ fds : int 21
## $ fds : int 14
## $ leaks :List of 4
## ..$ Deferred : int 50
## ..$ LuaRuntime: int 1
## ..$ QTimer : int 1
## ..$ Request : int 1
## $ maxrss : int 202020
## $ maxrss : int 68444
## $ qsize : int 0
## $ url : chr "http://localhost:8050"
## - attr(*, "class")= chr [1:2] "splash_debug" "list"
@@ -166,7 +168,7 @@ render_html(url = "http://marvel.com/universe/Captain_America_(Steve_Rogers)")

## {xml_document}
## <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
## [1] <head>\n<script type="text/javascript" async="async" src="http://dpm.demdex.net/id?d_rtbd=json&amp;d_ver=2&amp;d_ ...
## [1] <head>\n<script type="text/javascript" async="async" src="http://uncanny.marvel.com/id?callback=s_c_il%5B1%5D._se ...
## [2] <body id="index-index" class="index-index" onload="findLinks('myLink');">\n\n\t<div id="page_frame" style="overfl ...

``` r
@@ -197,21 +199,21 @@ print(har)
## --------HAR PAGES--------
## Page id: 1 , Page title: Poynter – A global leader in journalism. Strengthening democracy.
## --------HAR ENTRIES--------
## Number of entries: 18
## Number of entries: 41
## REQUESTS:
## Page: 1
## Number of entries: 18
## Number of entries: 41
## - http://www.poynter.org/
## - http://www.poynter.org/wp-content/plugins/easy-author-image/css/easy-author-image.css?ver=2016_06_24.1
## - http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css?ver=2016_06_24.1
## - http://www.poynter.org/wp-content/themes/poynter_timber/assets/scrollbar/jquery.mCustomScrollbar.min.css?ver=2016...
## - http://www.poynter.org/wp-content/plugins/jetpack/css/jetpack.css?ver=4.0.4
## - http://www.poynter.org/wp-content/themes/poynter_timber/style.css?ver=2016_06_24.1
## - http://cloud.webtype.com/css/162ac332-3b31-4b73-ad44-da375b7f2fe3.css?ver=2016_06_24.1
## - http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css?ver=2016_06_24.1
## ........
## - http://cloud.webtype.com/webtype/ff2/3/60a9547a-da5f-42cd-8e1f-769a99fc27cd?ec_token=8f7c4c4997246fd7fa920171c994...
## - http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/fonts/fontawesome-webfont.woff?v=4.4.0
## - http://cloud.webtype.com/webtype/ff2/3/7dac2f83-affe-4762-81f1-056f47b74dc7?ec_token=8f7c4c4997246fd7fa920171c994...
## - http://cloud.webtype.com/webtype/ff2/3/4ac7f809-9bdf-4acc-8bd5-a922f05f271b?ec_token=8f7c4c4997246fd7fa920171c994...
## - http://cloud.webtype.com/webtype/ff2/3/c6608520-1978-45ac-9061-74ada664cae4?ec_token=8f7c4c4997246fd7fa920171c994...
## - http://cloud.webtype.com/webtype/ff2/3/c6608520-1978-45ac-9061-74ada664cae4?ec_token=8f7c4c4997246fd7fa920171c994...
## - http://cloud.webtype.com/webtype/ff2/3/380e3672-840d-462a-83ee-2ea85a43504a?ec_token=8f7c4c4997246fd7fa920171c994...
## - http://cloud.webtype.com/webtype/ff2/3/c6369fc5-fc59-4a12-ac92-25afa6c567a0?ec_token=8f7c4c4997246fd7fa920171c994...

You can use [`HARtools::HARviewer`](https://github.com/johndharrison/HARtools/blob/master/R/HARviewer.R) — which this pkg import/exports — to get view the HAR in an interactive HTML widget.

@@ -287,14 +289,14 @@ library(testthat)
date()
```

## [1] "Tue Feb 21 11:04:49 2017"
## [1] "Tue Feb 21 16:54:03 2017"

``` r
test_dir("tests/")
```

## testthat results ========================================================================================================
## OK: 0 SKIPPED: 0 FAILED: 0
## OK: 8 SKIPPED: 0 FAILED: 0
##
## DONE ===================================================================================================================



BIN
img/cap.png View File

Before After
Width: 1024  |  Height: 768  |  Size: 327KB Width: 1024  |  Height: 768  |  Size: 327KB

+ 14
- 6
tests/testthat/test-splash.R View File

@@ -1,12 +1,9 @@
context("basic functionality")
test_that("we can do something", {

spact <- splash_active()

expect_that(spact, equals(TRUE))

if (spact) {

xpct <- function(x) {
spact <- splash_active()
expect_that(spact, equals(TRUE))
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"))
@@ -14,7 +11,18 @@ test_that("we can do something", {
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"))
}

spact <- splash_active()

if (spact) {
xpct()
} else {
install_splash()
vm <- start_splash()
Sys.sleep(15)
xpct()
stop_splash(vm)
}

})

Loading…
Cancel
Save