tests/testthat/test-api.R

test_that("API errors for a bad path", {
  expect_error(wmata_api("Rail"))
})

test_that("API errors with message", {
  expect_error(next_train(station = "XXX"))
})

test_that("API returns JSON for a proper path", {
  skip_if_no_key()
  Sys.sleep(0.11)
  x <- wmata_api("Rail.svc/json/jLines")
  expect_length(x, 1)
})

Try the metro package in your browser

Any scripts or data that you put into this service are public.

metro documentation built on Nov. 2, 2023, 6:06 p.m.