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

Fix tests #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions R/give_candygrams.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' @return A candy gram announcement
#'
#' @importFrom stringr str_detect str_to_title
#' @importFrom stringr str_detect str_to_title str_trim
#' @importFrom english as.english
#'
#' @export
Expand All @@ -21,16 +21,20 @@ give_candygrams <- function(person, number,

}

if (is.null(extra_message)) {

if (is.null(extra_message)) {
extra_message <- add_commentary(person, number)

} else {
extra_message <- glue::glue("{extra_message} {add_commentary(person, number)}")
}




number <- str_to_title(as.english(number))


glue::glue("{number} for {person}.")
stringr::str_trim(glue::glue("{number} for {person}.") + " " + extra_message)



Expand Down
5 changes: 4 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ give_candygrams("Glen Coco", 4)
give_candygrams("Gretchen Weiners", 4)
```


```{r}
give_candygrams("Glen Coco", 4,
extra_message = "Happy Birthday.")
```
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# meangirls

<!-- badges: start -->

<!-- badges: end -->

The goal of meangirls is to create quotes in the style of the 2004
Expand Down Expand Up @@ -82,7 +81,7 @@ number of candygrams a person gets.

``` r
give_candygrams("Taylor Zimmerman", 2)
#> Two for Taylor Zimmerman.
#> [1] "Two for Taylor Zimmerman."
```

### Extra comments
Expand All @@ -92,18 +91,24 @@ You can also give extra commentary to your announcement:
``` r
give_candygrams("Taylor Zimmerman", 2,
extra_message = "Merry Christmas!")
#> Two for Taylor Zimmerman.
#> [1] "Two for Taylor Zimmerman. Merry Christmas!"
```

Some special cases trigger automatic extra commentary or special
behavior:

``` r
give_candygrams("Glen Coco", 4)
#> Four for Glen Coco.
#> [1] "Four for Glen Coco. You go, Glen Coco!"
```

``` r
give_candygrams("Gretchen Weiners", 4)
#> [1] "None for Grethen Weiners."
#> None for Gretchen Weiners.
```

``` r
give_candygrams("Glen Coco", 4,
extra_message = "Happy Birthday.")
#> [1] "Four for Glen Coco. Happy Birthday. You go, Glen Coco!"
```
4 changes: 2 additions & 2 deletions tests/testthat/test-give_candygrams.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("add_commentary compliments people with lots of grams", {
correct_result <- "You go, Glen Coco!"
correct_result <- "Four for Glen Coco. You go, Glen Coco!"

my_result <- add_commentary("Glen Coco", 4)
my_result <- give_candygrams("Glen Coco", 4)

expect_equal(my_result, correct_result)
})
Expand Down
Binary file added tests/testthat/testthat-problems.rds
Binary file not shown.