diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..c0d5ce1 --- /dev/null +++ b/circle.yml @@ -0,0 +1,7 @@ +machine: + ruby: + version: 2.1.5 + +test: + post: + - ruby tests/test_verifyurl.rb diff --git a/package.json b/package.json index 0ef31b0..b948723 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,5 @@ }, "description": "Simple JS game", "author": "https://twitter.com/brianamarie", - "version": "1.0.0", - "devDependencies": { - "jshint": "^2.8.0" - }, - "scripts": { - "test": "./node_modules/jshint/bin/jshint stats.js" - } + "version": "1.0.0" } diff --git a/script/check-remotes b/script/check-remotes new file mode 100644 index 0000000..ae4e5e8 --- /dev/null +++ b/script/check-remotes @@ -0,0 +1,51 @@ +#!/bin/sh + +set -e + +# setup environment +export PATH="/usr/share/rbenv/shims:$PATH" + +echo "hostname: $(hostname)" +echo "pwd: $(pwd)" +git --version + +# store remotes in variable +CURRENT_REMOTES=$(git remote -v) + +# print out the remote information +echo $CURRENT_REMOTES + +# set URL stored for origin to ORIGIN variable +ORIGIN=$(git config remote.origin.url) + +# set URL for upstream to UPSTREAM variable +UPSTREAM=$(git config remote.upstream.url) + +# set origin length +ORIGIN_LENGTH=${#ORIGIN} + +# set length of output to size variable +CURRENT_LENGTH=${#CURRENT_REMOTES} + +# set desired length by using remote url +DESIRED_LENGTH=$(($ORIGIN_LENGTH + $ORIGIN_LENGTH + 161)) + +if [ $UPSTREAM = 'https://github.com/githubschool/github-games.git' ] +then + echo "The upstream is GitHubSchool/GitHubGames!" +else + echo "The upstream is incorrect." + exit 1 +fi + + +if [ $DESIRED_LENGTH -eq $CURRENT_LENGTH ] +then + echo "You have an upstream remote set." +else + echo "You do not have an upstream remote set." + exit 1 +fi + + +exit 0 diff --git a/tests/test_differentcolors.rb b/tests/test_differentcolors.rb new file mode 100644 index 0000000..0e77170 --- /dev/null +++ b/tests/test_differentcolors.rb @@ -0,0 +1,48 @@ +require 'test/unit' + +class TestDifferentColors < Test::Unit::TestCase + + def test_different_colors + #open file and read + file = File.read('./index.html') + + # search for color pieces + color_i_index = file.index('var i') + color_j_index = file.index('var j') + color_l_index = file.index('var l') + color_o_index = file.index('var o') + color_s_index = file.index('var s') + color_t_index = file.index('var t') + color_z_index = file.index('var z') + last_index = file.index('do the bit manipulation') + + color_i = file[color_i_index + 69...color_j_index - 11] + puts color_i + + color_j = file[color_j_index + 69...color_l_index - 11] + puts color_j + + color_l = file[color_l_index + 69...color_o_index - 9] + puts color_l + + color_o = file[color_o_index + 69...color_s_index - 9] + puts color_o + + color_s = file[color_s_index + 69...color_t_index - 10] + puts color_s + + color_t = file[color_t_index + 69...color_z_index - 9] + puts color_t + + color_z = file[color_z_index + 69...last_index - 71] + puts color_z + + # compare all pieces + + color_array = [color_i, color_j, color_l, color_o, color_s, color_t, color_z] + puts color_array.uniq == color_array + + assert(color_array.uniq == color_array, "You have multiple pieces with the same color!") + end + +end diff --git a/tests/test_speeddecrement.rb b/tests/test_speeddecrement.rb new file mode 100644 index 0000000..7f40a4f --- /dev/null +++ b/tests/test_speeddecrement.rb @@ -0,0 +1,27 @@ +require 'test/unit' + +class TestGameDecrement < Test::Unit::TestCase + + def test_game_decrement + # open file to read + file = File.read('./index.html') + + # search for decrement word + decrement_index = file.index('decrement') + min_index = file.index('min:') + puts decrement_index + puts '> ' + puts min_index + + # assign number after decrement to a variable + decrement = file[decrement_index + 11...min_index - 2] + puts decrement + + decrement_less_than_1 = decrement.to_f < 1.0 + decrement_greater_than_0 = decrement.to_f > 0.0 + # assert if that variable is between 0-1 + assert(decrement_less_than_1, "The rate of decrement is too high! Bring 'decrement' above 0 and below 1.") + assert(decrement_greater_than_0, "The rate of decrement is too slow. Bring 'decrement' above 0 and below 1.") + end + +end diff --git a/tests/test_speedmax.rb b/tests/test_speedmax.rb new file mode 100644 index 0000000..2f99067 --- /dev/null +++ b/tests/test_speedmax.rb @@ -0,0 +1,28 @@ +require 'test/unit' + +class TestGameSpeedMax < Test::Unit::TestCase + + def test_game_speed_max + # open file to read + file = File.read('./index.html') + + # search for decrement word + min_index = file.index('min:') + end_index = file.index('}, // how long') + puts min_index + puts '> ' + puts end_index + + # assign number after decrement to a variable + min = file[min_index + 5 ...end_index] + + puts min + + min_less_than_1 = min.to_f < 1.0 + min_greater_than_0 = min.to_f > 0.0 + # assert if that variable is between 0-1 + assert(min_less_than_1, "The speed is too high! Bring 'min' above 0 and below 1.") + assert(min_greater_than_0, "The speed too slow. Bring 'min' above 0 and below 1.") + end + +end diff --git a/tests/test_speedstart.rb b/tests/test_speedstart.rb new file mode 100644 index 0000000..ba6e9be --- /dev/null +++ b/tests/test_speedstart.rb @@ -0,0 +1,28 @@ +require 'test/unit' + +class TestGameStart < Test::Unit::TestCase + + def test_game_start + # open file to read + file = File.read('./index.html') + + # search for decrement word + start_index = file.index('start:') + decrement_index = file.index('decrement:') + puts start_index + puts '> ' + puts decrement_index + + # assign number after decrement to a variable + start = file[start_index + 7...decrement_index - 2] + + puts start + + start_less_than_1 = start.to_f < 1.0 + start_greater_than_0 = start.to_f > 0.0 + # assert if that variable is between 0-1 + assert(start_less_than_1, "The start speed is too high! Bring it above 0 and below 1.") + assert(start_greater_than_0, "The start speed too slow. Bring it above 0 and below 1.") + end + +end diff --git a/tests/test_verifyurl.rb b/tests/test_verifyurl.rb new file mode 100644 index 0000000..fc47c6d --- /dev/null +++ b/tests/test_verifyurl.rb @@ -0,0 +1,46 @@ +require 'test/unit' + +class TestGameStart < Test::Unit::TestCase + + def test_game_start + # open file to read + file = File.read('./README.md') + + # get url for remote + remote = `git config remote.origin.url` + print 'Remote URL: ' + puts remote + + # get username in remote url + split_remote = remote.to_s.split('/') + username_remote_ssh = split_remote[1] + username_remote_https = split_remote[4] + if + username_remote_ssh.length > 0 + then + username_remote = username_remote_ssh + else username_remote = username_remote_https + end + + user_remote_split = username_remote.to_s.split('.') + user_remote = user_remote_split[0] + print 'Username in remote: ' + puts user_remote + + # search for README url, assign to link + link_index = file.index('at:') + link_end_index = file.index('>> _*SUP') + link = file[link_index + 4...link_end_index - 3] + + # get username from link in readme + split_readme = link.to_s.split('/') + username_readme = split_readme[3] + print 'Username in README: ' + puts username_readme + + + # compare those strings, pass test if they're equal + assert_equal(user_remote, username_readme, "The URL to the game in the README.md doesn't match the username in the remote repository.") + end + +end