paleolimbot / rbbt

R Interface to the Better BiBTex Zotero Connector
142 stars 25 forks source link

Add bbt_update_bib #27

Closed Robinlovelace closed 2 years ago

Robinlovelace commented 2 years ago
Robinlovelace commented 2 years ago

This is a starter for 10. Any advice on how best to add tests appreciated. Thanks!

paleolimbot commented 2 years ago

Awesome! The only things I see are

bib_file <- tempfile(fileext = ".bib")
mock_content <- sprintf('

---
bibliography: %s
---

This file contains a reference to @dunnington_etal18.

', bib_file)

rmd_file <- tempfile(fileext = ".Rmd")
readr::write_file(mock_content, rmd_file)

# run bbt_update_bib()

# expect_match(readr::read_file(bib_file), "dunnington_etal18")

unlink(c(rmd_file, bib_file))

Thank you!

Robinlovelace commented 2 years ago

Good news, I got the tests to pass after adding your reference to Zotero and making it run, great way of testing this. There may well be other tweaks needed but happy with this from my perspective.

Robinlovelace commented 2 years ago

Just getting this message on devtools::test() now and not sure why:

> devtools::test()
ℹ Loading rbbt
ℹ Testing rbbt
✔ |  OK F W S | Context
✔ |   6       | bbt-libraries [0.1 s]                                                                                                             
✔ |  15   2   | bbt [1.7 s]                                                                                                                       
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning (test-bbt.R:33:5): actions work
System clipboard contained no readable text. Returning NULL.
Backtrace:
 1. clipr::read_clip() test-bbt.R:33:4

Warning (test-bbt.R:36:5): actions work
Coercing content to character
Backtrace:
 1. clipr::write_clip(prev_clip) test-bbt.R:36:4
 2. clipr:::chosen_write_clip(...)
 3. clipr:::write_nix(...)
 4. clipr:::render_object(content, object_type, breaks, .dots)
 5. clipr:::flat_str(content, breaks)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ |   3       | detect-citations                                                                                                                  
✔ |   1       | update [0.2 s]                                                                                                                    
✔ |   8       | write-bib [0.5 s]                                                                                                                 

══ Results ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 2.5 s

[ FAIL 0 | WARN 2 | SKIP 0 | PASS 33 ]
Robinlovelace commented 2 years ago

But when testing with Ctl+Shift+E I get this :tada:

Duration: 12.5s

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

R CMD check succeeded

paleolimbot commented 2 years ago

Thanks for this! I tweaked some details and added an RStudio addin...it's so good that I changed the recommended approach for RMarkdown integration!