Last active
August 29, 2015 14:16
-
-
Save beaugaines/28cc7c252378db6032a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.import(file) | |
| CSV.foreach(file.path, headers: true) do |row| | |
| data = row.to_hash | |
| Plan.create(title: data['Title']) | |
| steps = data['Steps'].split(/\d/).reject(&:empty?) | |
| steps.map! { |s| s.gsub(/^\.\s+/, '') } | |
| .map! { |s| s.gsub(/\n|:/, '') } | |
| .map! { |s| s.split(/Expected Result/) } | |
| .each { |s| Step.create(description: s[0], result: s[1]) } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment