Adding all tracks, I guess

This commit is contained in:
2018-08-14 17:28:48 -05:00
parent 51aa078388
commit fab045379a
47 changed files with 3402 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/**
* Your implmentation of the Hello World exercise
*/
component {
/**
* @returns A string greeting the world
*/
function hello() {
return '';
}
}

View File

@@ -0,0 +1,19 @@
component extends="testbox.system.BaseSpec" {
function beforeAll(){
SUT = createObject( 'HelloWorld' );
}
function run(){
describe( "My HelloWorld class", function(){
it( 'Say Hi!', function(){
expect( SUT.hello() ).toBe( 'Hello, World!' );
});
});
}
}

View File

@@ -0,0 +1,37 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
* * * *
To run the code in this exercise, you will only need to have [CommandBox CLI installed](https://ortus.gitbooks.io/commandbox-documentation/content/setup/installation.html). This binary runs CFML code from the command line.
To run the tests, `cd` into the exercise folder and run the following:
```bash
box task run TestRunner
# Or start up a test watcher that will rerun when files change
box task run TestRunner --:watcher
```
The tests leverage a library called TestBox which supports xUnit and BDD style of testing. All test suites will be written in the [BDD style](https://testbox.ortusbooks.com/content/primers/bdd/specs.html) which uses closures to define test specs. You won't need to worry about installing TestBox. The CLI test runner will take care of that for you. You just need to be connected to the internet the first time you run it. You can read more about it here:
[https://testbox.ortusbooks.com/content/](https://testbox.ortusbooks.com/content/)
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@@ -0,0 +1,103 @@
/**
* I am a CommandBox task runner which you can use to test your implementation of this exercise against the
* provided test suite. To use me, open the CommandBox CLI and run this:
*
* CommandBox> task run TestRunner
*
* To start up a test watcher that will automatically rerun the test suite every time you save a file change, run this:
*
* CommandBox> task run TestRunner --watcher
*
*/
component {
/**
* @solution Runs the tests against the solution
* @watcher Start up a file watch that re-runs the tests on file changes. Use Ctrl-C to stop
*/
function run( boolean solution=false, boolean watcher=false ) {
ensureTestBox();
if( watcher ) {
// Tabula rasa
command( 'cls' ).run();
// Start watcher
watch()
.paths( '*.cfc' )
.inDirectory( getCWD() )
.withDelay( 500 )
.onChange( function() {
// Clear the screen
command( 'cls' )
.run();
// This is neccessary so changes to tests get picked up right away.
pagePoolClear();
runTests( solution );
} )
.start();
} else {
runTests( solution );
}
}
/**
* Make sure the TestBox framework is installed
*/
private function ensureTestBox() {
var excerciseRoot = getCWD();
var testBoxRoot = excerciseRoot & '/testbox';
if( !directoryExists( testBoxRoot ) ) {
print.boldYellowLine( 'Installing some missing dependencies for you!' ).toConsole();
command( 'install' )
.inWorkingDirectory( excerciseRoot )
.run();
}
// Bootstrap TestBox framework
filesystemUtil.createMapping( '/testbox', testBoxRoot );
}
/**
* Invoke TestBox to run the test suite
*/
private function runTests( boolean solution=false ) {
// Create TestBox and run the tests
testData = new testbox.system.TestBox()
.runRaw( directory = {
// Find all CFCs...
mapping = filesystemUtil.makePathRelative( getCWD() ),
// ... in this directory ...
recurse = false,
// ... whose name ends in "test"
filter = function( path ) {
return path.reFind( ( solution ? 'Solution' : '' ) & 'Test.cfc$' );
}
} )
.getMemento();
// Print out the results with ANSI formatting for the CLI
getInstance( 'CLIRenderer@testbox-commands' )
.render( print, testData, true );
print.toConsole();
// Set proper exit code
if( testData.totalFail || testData.totalError ) {
setExitCode( 1 );
}
}
}

View File

@@ -0,0 +1,8 @@
{
"dependencies":{
"testbox":"^2.5.0+107"
},
"installPaths":{
"testbox":"testbox"
}
}

View File

@@ -0,0 +1,37 @@
<!---
This file will only be used if you want to start up a web server in this directory. You can do so by running:
$> box
CommandBox> install
CommandBox> server start
However, this is not necessary unless you really just want to use the HTML reporters on TestBox.
Ideally, you'll skip the need for this file entirely and just run the tests directly frm the CLI like this:
CommandBox> task run TestRunner
--->
<cfsetting showDebugOutput="false">
<cfparam name="url.reporter" default="simple">
<cfscript>
// get a list of all CFCs in this folder whose name looks like "XXXTest.cfc"
// And turn it into compnent path relative to the web root
url.bundles = directoryList(
path=expandPath( '/' ),
filter='*Test.cfc' )
.map( function( path ) {
return path
.replaceNoCase( expandPath( '/' ), '' )
.left( -4 )
} )
.toList();
</cfscript>
<!--- Ensure TestBox --->
<cfif fileExists( "/testbox/system/runners/HTMLRunner.cfm" )>
<!--- Include the TestBox HTML Runner --->
<cfinclude template="/testbox/system/runners/HTMLRunner.cfm">
<cfelse>
Oops, you don't have TestBox installed yet! Please run <b>box install</b> from the root of your excercise folder and refresh this page.
</cfif>