Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe change suggested use_cassette usage? #86

Closed
sckott opened this issue Jan 9, 2019 · 3 comments
Closed

Maybe change suggested use_cassette usage? #86

sckott opened this issue Jan 9, 2019 · 3 comments
Milestone

Comments

@sckott
Copy link
Collaborator

sckott commented Jan 9, 2019

I have been doing (assume the expect_is call fails)

test_that("foobar works", {
    vcr::use_cassette("foobar", {
        a <- foobar()
        expect_is(a, "character")
    })
})

But when the expect_is line fails, the traceback gives the line for the vcr::use_cassette call, instead of the expect_is line.

if we change to:

vcr::use_cassette("foobar", {
  test_that("foobar works", {
      a <- foobar()
      expect_is(a, "character")
  })
})

the traceback points to the actual test line that failed


Make sure this doesn't lead to othe problems

@sckott sckott modified the milestones: v0.3, v0.2.2 Jan 9, 2019
sckott added a commit to ropensci-archive/zbank that referenced this issue Jan 10, 2019
@sckott sckott closed this as completed in 0017366 Jan 10, 2019
@dpprdan
Copy link
Member

dpprdan commented Jan 16, 2019

Wouldn't this also be an option?

test_that("foobar works", {
    vcr::use_cassette("foobar", {
        a <- foobar()
    })
    expect_is(a, "character")
})

Or rather, is there a problem with it, I am not seeing ATM? Traceback seems to work with it.

@sckott
Copy link
Collaborator Author

sckott commented Jan 16, 2019

You're right. Thanks for the ping on this. I'll add to the docs the various ways you can arrange the code blocks and test lines

sckott added a commit that referenced this issue Jan 16, 2019
@sckott
Copy link
Collaborator Author

sckott commented Jan 16, 2019

https://github.com/ropensci/vcr#best-practices

sckott added a commit to ropensci-books/http-testing that referenced this issue Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants