Skip to content

Commit

Permalink
Updated basic rap score with new col name (#63)
Browse files Browse the repository at this point in the history
* Updated basic rap score with new col name

* Update derive_basic_rap_scores unit test

---------

Co-authored-by: ldavies99 <[email protected]>
  • Loading branch information
CHCRowley and ldavies99 authored Nov 15, 2023
1 parent afed2b3 commit 14d41b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions R/derive_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ derive_vars <- function(data) {

#' @title Derive language status
#'
#' @description Derve the status of each programmming language as "access" (access only), "knowledge" (knowledge only), "both" or "neither".
#' @description Derive the status of each programmming language as "access" (access only), "knowledge" (knowledge only), "both" or "neither".
#'
#' @param data tidied CARS wave 3 data (data.frame).
#'
Expand Down Expand Up @@ -85,7 +85,7 @@ derive_basic_rap_scores <- function(data) {
"prac_open_source_own",
"prac_version_control",
"prac_review",
"prac_AQUA_book",
"prac_development_QA",
"doc_comments",
"doc_readme")

Expand All @@ -102,7 +102,7 @@ derive_basic_rap_scores <- function(data) {
"open_code_score",
"version_control_score",
"peer_review_score",
"AQUA_book_score",
"development_QA_score",
"doc_score")

high_vals <- c("Regularly", "All the time")
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-derive_basic_rap_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ dummy_data <- data.frame(code_freq = c("Never", rep("Sometimes", 4)),
prac_open_source_own = c(NA, "All the time", "Regularly", "Sometimes", "Rarely"),
prac_version_control = c(NA, "Never" ,"All the time", "Regularly", "Sometimes"),
prac_review = c(NA, "Rarely", "Never", "All the time", "Regularly"),
prac_AQUA_book = c(NA, "Sometimes", "Rarely", "Never", "All the time"),
prac_development_QA = c(NA, "Sometimes", "Rarely", "Never", "All the time"),
doc_readme = c(NA, "Regularly", "Sometimes", "Rarely", "Never"),
doc_comments = c(NA, "All the time", "Regularly", "Sometimes", "Rarely"))

test_that("derive_basic_rap_scores validation works", {

dummy_data <- data.frame()

expect_error(derive_basic_rap_scores(dummy_data), "Unexpected input - missing column names: code_freq\nprac_use_open_source\nprac_open_source_own\nprac_version_control\nprac_review\nprac_AQUA_book\ndoc_comments\ndoc_readme")
expect_error(derive_basic_rap_scores(dummy_data), "Unexpected input - missing column names: code_freq\nprac_use_open_source\nprac_open_source_own\nprac_version_control\nprac_review\nprac_development_QA\ndoc_comments\ndoc_readme")

})

Expand All @@ -24,14 +24,14 @@ test_that("derive_basic_rap_scores output is as expected", {
prac_open_source_own = c(NA, "All the time", "Regularly", "Sometimes", "Rarely"),
prac_version_control = c(NA, "Never" ,"All the time", "Regularly", "Sometimes"),
prac_review = c(NA, "Rarely", "Never", "All the time", "Regularly"),
prac_AQUA_book = c(NA, "Sometimes", "Rarely", "Never", "All the time"),
prac_development_QA = c(NA, "Sometimes", "Rarely", "Never", "All the time"),
doc_readme = c(NA, "Regularly", "Sometimes", "Rarely", "Never"),
doc_comments = c(NA, "All the time", "Regularly", "Sometimes", "Rarely"),
use_open_source_score = c(NA, 1, 0, 0, 0),
open_code_score = c(NA, 1, 1, 0, 0),
version_control_score = c(NA, 0, 1, 1, 0),
peer_review_score = c(NA, 0, 0, 1, 1),
AQUA_book_score = c(NA, 0, 0, 0, 1),
development_QA_score = c(NA, 0, 0, 0, 1),
doc_score = c(NA, 1, 0, 0, 0),
basic_rap_score = c(NA, 3, 2, 2, 2))

Expand Down

0 comments on commit 14d41b5

Please sign in to comment.