Skip to content

Instantly share code, notes, and snippets.

@eamexicano
Created Apr 26, 2012
Embed
What would you like to do?
jasmine src and spec creation
#!/bin/sh
if [ -n "$1" ]; then
echo "Creating SOURCE and SPECS files.";
echo "SOURCE -> src/$1.js";
tee src/"$1".js > /dev/null <<SOURCE
function $1(){
}
SOURCE
echo "SPECS -> spec/$1Spec.js";
tee spec/"$1"Spec.js > /dev/null <<SPEC
describe("$1", function() {
var $1;
beforeEach(function() {
$1 = new $1();
console.log("Add configuration for $1 test");
});
// Add tests
it("should have a general test", function() {
expect(true).toEqual(false);
});
// Describe scenarios with particular setup.
describe("when you need a particular configuration", function() {
beforeEach(function() {
console.log("Add configuration for a particular $1 test");
});
it("should have a particular test", function() {
expect(true).toEqual(false);
});
});
});
SPEC
sed "/<!-- include source files here... -->/ a\
<script type='text\/javascript' src='spec\/$1Spec.js'><\/script>" SpecRunner.html > temp.html;
sed "/<!-- include spec files here... -->/ a\
<script type='text\/javascript' src='src\/$1.js'><\/script>" temp.html > SpecRunner.html;
rm temp.html;
echo "Open SpecRunner.html in your browser.";
echo "Update spec/$1Spec.js tests";
echo "Update src/$1.js code"
else
echo "Create SOURCE and SPECS files, so run docs.sh with a name";
echo "sh docs.sh leSource";
echo "-> src/leSource.js";
echo "-> spec/leSourceSpec.js";
echo "next 2 lines added in SpecRunner.html";
echo "-> <script type='text/javascript' src='spec/leSourceSpec.js'></script>";
echo "-> <script type='text/javascript' src='spec/leSource.js'></script>";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment