Browse files

allow more of less whitespace in answer options. closes #179

  • Loading branch information...
1 parent edbff2f commit 1123733ff3a902d4c7e7e2da7433bcd9113f2ad3 Mark Yoon committed Jul 11, 2011
Showing with 18 additions and 1 deletion.
  1. +16 −0 features/redcap_parser.feature
  2. +1 −0 features/support/redcap_whitespace.csv
  3. +1 −1 lib/surveyor/redcap_parser.rb
View
16 features/redcap_parser.feature
@@ -39,3 +39,19 @@ Feature: Survey creation
||
And there should be 2 answers with:
||
+ @focus
+ Scenario: with different whitespace
+ Given I parse redcap file "redcap_whitespace.csv"
+ Then there should be 1 survey with:
+ ||
+ And there should be 2 questions with:
+ ||
+ And there should be 7 answers with:
+ | reference_identifier | text |
+ | 1 | Lexapro |
+ | 2 | Celexa |
+ | 3 | Prozac |
+ | 4 | Paxil |
+ | 5 | Zoloft |
+ | 0 | No |
+ | 1 | Yes |
View
1 features/support/redcap_whitespace.csv
@@ -0,0 +1 @@
+Variable / Field Name,Form Name,Field Units,Section Header,Field Type,Field Label,Choices OR Calculations,Field Note,Text Validation Type,Text Validation Min,Text Validation Max,Identifier?,Branching Logic (Show field only if...),Required Field? meds,demographics,,,checkbox,Is patient taking any of the following medications? (check all that apply),"1, Lexapro | 2, Celexa | 3, Prozac | 4, Paxil | 5, Zoloft",,,,,,, diabetes,demographics,,,dropdown,Patient has a diagnosis of diabetes mellitus?,"0,No|1,Yes",,,,,,,
View
2 lib/surveyor/redcap_parser.rb
@@ -185,7 +185,7 @@ def self.build_and_set(context, r)
puts "\n!!! skipping answer: file"
end
(r[:choices_or_calculations] || r[:choices_calculations_or_slider_labels]).to_s.split("|").each do |pair|
- aref, atext = pair.strip.split(", ")
+ aref, atext = pair.split(",").map(&:strip)
if aref.blank? or atext.blank?
puts "\n!!! skipping answer #{pair}"
else

0 comments on commit 1123733

Please sign in to comment.