Improving bonfire flow, working on seed.js

This commit is contained in:
Nathan Leniz
2015-01-22 18:44:25 -05:00
parent 8a3618e366
commit e0311210e0
4 changed files with 25 additions and 15 deletions

View File

@ -548,6 +548,13 @@ div.CodeMirror-scroll {
}
.bonfire-instructions p {
padding: 0;
}
.bonfire-instructions {
margin-bottom: 2px;
}
//uncomment this to see the dimensions of all elements outlined in red
//* {
// border-color: red;

View File

@ -44,7 +44,7 @@ var editorValue;
if (challengeSeed) {
editorValue = challengeSeed;
editorValue = challengeSeed + '\n\n' + challengeEntryPoint;
} else {
editorValue = nonChallengeValue;
}
@ -100,9 +100,11 @@ var replaceQuotesInTests = function() {
var tests;
var testSalt = Math.random();
var scrapeTests = function(userJavaScript) {
var checkIfUserSuppliedEntry = new RegExp(challengeEntryPointNegate, 'g');
var userEntryCheck = checkIfUserSuppliedEntry.test(userJavaScript);
@ -115,6 +117,11 @@ var scrapeTests = function(userJavaScript) {
for (var i = 0; i < publicTests.length; i++) {
userJavaScript += '\n' + publicTests[i];
}
for (var i = 0; i < privateTests.length; i++) {
userJavaScript += '\n' + privateTests[i];
}
var counter = 0;
var regex = new RegExp(/(expect(\s+)?\(.*\;)|(assert(\s+)?\(.*\;)|(assert\.\w.*\;)|(.*\.should\..*\;)/);
var match = regex.exec(userJavaScript);
@ -130,10 +137,6 @@ var scrapeTests = function(userJavaScript) {
match = regex.exec(userJavaScript);
}
//for (publicTest in publicTests) {
// console.log(publicTest);
// tests.push(publicTest);
//}
if (tests) replaceQuotesInTests();
return userJavaScript;
};
@ -198,7 +201,7 @@ var createTestDisplay = function() {
var assert = chai.assert;
var expect = chai.expect;
var should = chai.should();
console.log(should);
var reassembleTest = function(test, data) {
var lineNum = test.line;
var regexp = new RegExp("\/\/" + lineNum + testSalt);
@ -219,6 +222,7 @@ var runTests = function(err, data) {
var output = eval(reassembleTest(test, data));
}
} catch(error) {
arr[ix].err = error.name + ":" + error.message;
} finally {
if (!test) {

View File

@ -1,7 +1,7 @@
[
{
"name": "Palindrome Tester",
"difficulty": 1, // should be a range from 1-5
"difficulty": 1,
"description": [
"Your job is to determine if a provided string is a palindrome.",
"The definition of a palindrome can be found at http://en.wikipedia.org/wiki/Palindrome.",
@ -20,9 +20,9 @@
"assert.deepEqual(palindrome(\"nope\"), false);"
],
"challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n",
"challengeEntryPoint": "palindrome(\"eye\")",
"challengeEntryPoint": "palindrome(\"eye\");",
"bonfireNumber": 1,
"challengeEntryPointNegate" : "palindrome\\([^str].*\\;",
"challengeEntryPointNegate" : "palindrome\\([^str].*\\;"
},
{
"name": "Validate US Telephone Numbers",
@ -61,7 +61,7 @@
"challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n",
"challengeEntryPoint": "telephoneCheck(\"555-555-5555\")",
"bonfireNumber": 2,
"challengeEntryPointNegate" : "palindrome\\([^str].*\\;",
"challengeEntryPointNegate" : "palindrome\\([^str].*\\;"
}
]

View File

@ -22,11 +22,10 @@ block content
.panel.panel-primary.panel-bonfire
.panel-heading.text-center #{name} (Level #{difficulty} bonfire)
.panel.panel-body
h4 Details
h5
ol
.well
.text-justify.bonfire-instructions
for sentence in description
li!= sentence
p.bonfire-instructions!= sentence
form.code
.form-group.codeMirrorView
textarea#codeEditor(autofocus=true)