Permalink
Browse files

run tests through jasmine-headless-webkit and guard

  • Loading branch information...
1 parent 394eb5d commit a2eae6d915397c23f60a314e51329b56d300ee4e @ryanb committed Aug 29, 2011
View
@@ -7,7 +7,7 @@ gem 'jquery-rails'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'will_paginate', '3.0.pre2'
gem 'whenever', :require => false
-gem 'go_gtp', '0.0.4', :require => 'go/gtp', :git => "git://github.com/JEG2/go_gtp.git"
+gem 'go_gtp', '0.0.5.alpha', :git => "git://github.com/JEG2/go_gtp.git"
gem 'stalker', '0.5.0'
gem 'oily_png', '0.1.0'
gem 'exception_notification', :git => 'git://github.com/rails/exception_notification.git', :require => 'exception_notifier'
@@ -24,11 +24,12 @@ group :development do
gem 'mongrel', '1.2.0.pre2'
gem 'nifty-generators'
gem 'thin'
+ gem 'foreman'
end
group :test do
gem 'mocha'
gem 'factory_girl_rails'
- gem 'guard'
gem 'guard-rspec'
+ gem 'guard-jasmine-headless-webkit'
end
View
@@ -1,8 +1,8 @@
GIT
remote: git://github.com/JEG2/go_gtp.git
- revision: 2753f3ebeb3c058bfc05eca20810df67557844c6
+ revision: a1cc912436c8e0bac10bca693ce583c8baf2a0c4
specs:
- go_gtp (0.0.4)
+ go_gtp (0.0.5.alpha)
GIT
remote: git://github.com/rails/exception_notification.git
@@ -67,7 +67,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.1.2)
- configuration (1.2.0)
daemons (1.0.10)
diff-lcs (1.1.2)
erubis (2.6.6)
@@ -82,25 +81,33 @@ GEM
addressable (>= 2.1.1)
rack (>= 1.0.1)
ffi (1.0.9)
+ foreman (0.19.0)
+ term-ansicolor (~> 1.0.5)
+ thor (>= 0.13.6)
gem_plugin (0.2.3)
- guard (0.3.0)
- open_gem (~> 1.4.2)
+ guard (0.6.2)
thor (~> 0.14.6)
- guard-rspec (0.2.0)
- guard (>= 0.2.2)
+ guard-jasmine-headless-webkit (0.2.0)
+ guard (>= 0.4.0)
+ jasmine-headless-webkit (>= 0.3.0)
+ guard-rspec (0.4.2)
+ guard (>= 0.4.0)
highline (1.6.1)
i18n (0.5.0)
jasmine (1.0.2.1)
json_pure (>= 1.4.3)
rack (>= 1.1)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
+ jasmine-core (1.1.0.rc3)
+ jasmine-headless-webkit (0.6.3)
+ coffee-script (>= 2.2)
+ jasmine-core (~> 1.1.beta)
+ multi_json
+ rainbow
jquery-rails (0.2.4)
rails (~> 3.0)
json_pure (1.4.6)
- launchy (0.3.7)
- configuration (>= 0.0.5)
- rake (>= 0.8.1)
mail (2.2.12)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -159,8 +166,6 @@ GEM
oa-enterprise (= 0.1.5)
oa-oauth (= 0.1.5)
oa-openid (= 0.1.5)
- open_gem (1.4.2)
- launchy (~> 0.3.5)
polyglot (0.3.1)
pyu-ruby-sasl (0.0.3.2)
rack (1.2.1)
@@ -184,7 +189,8 @@ GEM
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
- rake (0.8.7)
+ rainbow (1.1.1)
+ rake (0.9.2)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (2.0.1)
@@ -212,6 +218,7 @@ GEM
stalker (0.5.0)
beanstalk-client
json_pure
+ term-ansicolor (1.0.6)
thin (1.2.11)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
@@ -234,8 +241,9 @@ DEPENDENCIES
capistrano
exception_notification!
factory_girl_rails
- go_gtp (= 0.0.4)!
- guard
+ foreman
+ go_gtp (= 0.0.5.alpha)!
+ guard-jasmine-headless-webkit
guard-rspec
jasmine
jquery-rails
View
@@ -1,17 +1,29 @@
-# A sample Guardfile
-# More info at https://github.com/guard/guard#readme
+spec_location = "spec/javascripts/%s_spec"
+
+guard 'jasmine-headless-webkit' do
+ watch(%r{^app/views/.*\.jst$})
+ watch(%r{^app/coffeescripts/(.*)\.coffee$}) { |m| newest_js_file(spec_location % m[1]) }
+ watch(%r{^public/javascripts/(.*)\.js$}) { |m| newest_js_file(spec_location % m[1]) }
+ watch(%r{^app/assets/javascripts/(.*)\.(js|coffee)$}) { |m| newest_js_file(spec_location % m[1]) }
+ watch(%r{^spec/javascripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) }
+end
+
guard 'rspec', :version => 2 do
- watch(%r{^spec/.+_spec\.rb})
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
- watch('spec/spec_helper.rb') { "spec" }
-
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec/" }
+
# Rails example
- watch('spec/spec_helper.rb') { "spec" }
- watch('config/routes.rb') { "spec/routing" }
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
- watch(%r{^spec/.+_spec\.rb})
- watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
- watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
- watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec/" }
+ watch('spec/spec_helper.rb') { "spec/" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
+
View
@@ -0,0 +1,3 @@
+beanstalk: beanstalkd
+worker: script/worker
+faye: rackup faye.ru -s thin -E production
@@ -1,10 +1,13 @@
-class GoGame
+class @GoGame
constructor: ->
@goban = new Goban
handicap: $('#board').data('handicap')
moves: $('#board').data('moves')
started: $('#board').data('started')
finished: $('#board').data('finished')
-
-@GoGame = GoGame
+ move: (moveString) ->
+ move = @goban.addMove(moveString)
+ $("\##{move.position}").attr("class", move.color)
+ for capture in move.captures
+ $("\##{capture}").attr("class", "e")
@@ -1,6 +1,6 @@
-class GoMove
- captures: []
+class @GoMove
constructor: (@move, @color = "b") ->
+ @captures = []
if !@isResign() && !@isPass()
for position, index in @move.match(/../g)
if index == 0
@@ -13,5 +13,3 @@ class GoMove
isPass: ->
@move == "PASS"
-
-@GoMove = GoMove
@@ -1,26 +1,35 @@
-class Goban
+class @Goban
constructor: (options = {}) ->
- @size = 19
- @handicap = 0
- @started = false
- @finished = false
- @moves = []
+ @size = options.size || 19
+ @handicap = options.handicap || 0
+ @started = options.started || false
+ @finished = options.finished || false
+ @blackPositions = []
+ @whitePositions = []
@currentMoveIndex = 0
- @size = options.size if options.size
- @handicap = options.handicap if options.handicap
- @started = options.started if options.started
- @finished = options.finished if options.finished
- @addMoves(options.moves) if options.moves
+ @moves = []
+ @addMove(move) for move in options.moves.split("-") if options.moves
- addMoves: (moves) ->
- for move in moves.split("-")
- @moves.push new GoMove(move, @currentColor())
- @currentMoveIndex++
+ addMove: (moveString) ->
+ move = new GoMove(moveString, @currentColor())
+ @moves.push(move)
+ if move.color == "b"
+ @blackPositions.push(move.position)
+ @whitePositions = _.difference(@whitePositions, move.captures)
+ else
+ @whitePositions.push(move.position)
+ @blackPositions = _.difference(@blackPositions, move.captures)
+ @currentMoveIndex++
+ move
currentColor: ->
if @handicap > 0
if @currentMoveIndex % 2 then "b" else "w"
else
if @currentMoveIndex % 2 then "w" else "b"
-@Goban = Goban
+ captured: (color) ->
+ total = 0
+ for move in @moves
+ total += move.captures.length if move.color == color
+ total
@@ -1,19 +0,0 @@
-/* DO NOT MODIFY. This file was compiled Fri, 19 Aug 2011 23:45:03 GMT from
- * /Users/rbates/code/govsgo/app/coffeescripts/go_game.coffee
- */
-
-(function() {
- var GoGame;
- GoGame = (function() {
- function GoGame() {
- this.goban = new Goban({
- handicap: $('#board').data('handicap'),
- moves: $('#board').data('moves'),
- started: $('#board').data('started'),
- finished: $('#board').data('finished')
- });
- }
- return GoGame;
- })();
- this.GoGame = GoGame;
-}).call(this);
@@ -1,34 +0,0 @@
-/* DO NOT MODIFY. This file was compiled Fri, 19 Aug 2011 22:34:54 GMT from
- * /Users/rbates/code/govsgo/app/coffeescripts/go_move.coffee
- */
-
-(function() {
- var GoMove;
- GoMove = (function() {
- GoMove.prototype.captures = [];
- function GoMove(move, color) {
- var index, position, _len, _ref;
- this.move = move;
- this.color = color != null ? color : "b";
- if (!this.isResign() && !this.isPass()) {
- _ref = this.move.match(/../g);
- for (index = 0, _len = _ref.length; index < _len; index++) {
- position = _ref[index];
- if (index === 0) {
- this.position = position;
- } else {
- this.captures.push(position);
- }
- }
- }
- }
- GoMove.prototype.isResign = function() {
- return this.move === "RESIGN";
- };
- GoMove.prototype.isPass = function() {
- return this.move === "PASS";
- };
- return GoMove;
- })();
- this.GoMove = GoMove;
-}).call(this);
@@ -1,63 +0,0 @@
-/* DO NOT MODIFY. This file was compiled Fri, 19 Aug 2011 23:02:36 GMT from
- * /Users/rbates/code/govsgo/app/coffeescripts/goban.coffee
- */
-
-(function() {
- var Goban;
- Goban = (function() {
- function Goban(options) {
- if (options == null) {
- options = {};
- }
- this.size = 19;
- this.handicap = 0;
- this.started = false;
- this.finished = false;
- this.moves = [];
- this.currentMoveIndex = 0;
- if (options.size) {
- this.size = options.size;
- }
- if (options.handicap) {
- this.handicap = options.handicap;
- }
- if (options.started) {
- this.started = options.started;
- }
- if (options.finished) {
- this.finished = options.finished;
- }
- if (options.moves) {
- this.addMoves(options.moves);
- }
- }
- Goban.prototype.addMoves = function(moves) {
- var move, _i, _len, _ref, _results;
- _ref = moves.split("-");
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- move = _ref[_i];
- this.moves.push(new GoMove(move, this.currentColor()));
- _results.push(this.currentMoveIndex++);
- }
- return _results;
- };
- Goban.prototype.currentColor = function() {
- if (this.handicap > 0) {
- if (this.currentMoveIndex % 2) {
- return "b";
- } else {
- return "w";
- }
- } else {
- if (this.currentMoveIndex % 2) {
- return "w";
- } else {
- return "b";
- }
- }
- };
- return Goban;
- })();
- this.Goban = Goban;
-}).call(this);
Oops, something went wrong.

0 comments on commit a2eae6d

Please sign in to comment.