ruby-chess 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3a4ce154416026e554379b3a5ca09ca1f7b37ac
4
- data.tar.gz: 2f4a80afbe2e50cda73bfebbfcf301cbf183bb9c
3
+ metadata.gz: b1b894b21c69fe96008a3f0aa9d278b088922def
4
+ data.tar.gz: 83a5adfcd584129560509a38d4f77b330415a47b
5
5
  SHA512:
6
- metadata.gz: 75219a358a760de19304d904ba23861a220afc57e24fb111e9fb92ef866af25ce3590d4e80af11be10f9f1cc633516cb411537c2ccdee40f2741c29a44dd2f9a
7
- data.tar.gz: 596000ad217c193bb07402d35cefc435c0f4dbfcabaf9032048bafb1e7b88e553d1e37189eb35d147907cfc2f56721fc824817b3a2c694cd3efc6a2691525dfb
6
+ metadata.gz: 83ab88ae8b33c15e38c7f5cef45bee2f16fc906b324a6eb2b7d6e5f5134be7e17b02d3a560325387cc4ad7d64ab78815c3c938efd74a3d27e3d7bf3ee41cecff
7
+ data.tar.gz: 280b21f9bb99c26c06c2906a80a18e7dc47615da1005f79d7d251302682b8157d6ba6cf07d09b903093b36126d370bbf3f2e2e0d325b5ba118e9ca75500b7063
@@ -23,8 +23,8 @@ class Game
23
23
 
24
24
  def undo
25
25
  move = @moves.pop
26
- piece = at(*move[:piece][:point_a])
27
- new_piece = piece.class.new(*move[:piece][:point_b])
26
+ piece = at(*move[:piece][:point_b])
27
+ new_piece = piece.class.new(*move[:piece][:point_a])
28
28
  capture = move[:capture]
29
29
 
30
30
  @board.remove(piece)
@@ -31,12 +31,6 @@ class GameTest < Minitest::Test
31
31
  assert_kind_of BlackPawn, this_game.at(6,5)
32
32
  end
33
33
 
34
- def test_game_can_undo_moves
35
- game = white_in_check
36
- 2.times {game.undo}
37
- assert_kind_of EmptySpace, game.at(1,3)
38
- end
39
-
40
34
  def test_cannot_play_while_in_check
41
35
  game = white_in_check
42
36
  assert_raises(Game::IllegalMove) do
@@ -0,0 +1,40 @@
1
+ require_relative '../lib/chess'
2
+
3
+ require 'minitest/autorun'
4
+
5
+ class UndoTest < Minitest::Test
6
+
7
+ def white_in_check
8
+ game = Game.new
9
+ game.play([4,1],[4,3])
10
+ game.play([3,6],[3,5])
11
+ game.play([6,1],[6,3])
12
+ game.play([2,7],[6,3])
13
+ game
14
+ end
15
+
16
+ def test_game_can_undo_moves
17
+ game = white_in_check
18
+ 2.times {game.undo}
19
+ assert_kind_of EmptySpace, game.at(6,3)
20
+ end
21
+
22
+ def test_undo_adds_removed_pieces
23
+ game = Game.new
24
+ game.play([4,1],[4,3])
25
+ game.play([3,6],[3,4])
26
+ game.play([4,3],[3,4])
27
+ game.undo
28
+ assert_kind_of BlackPawn, game.at(3,4)
29
+ end
30
+
31
+ def test_undo_reverses_the_last_move
32
+ game = Game.new
33
+ game.play([4,1],[4,3])
34
+ game.play([3,6],[3,4])
35
+ game.play([4,3],[3,4])
36
+ game.undo
37
+ assert_kind_of WhitePawn, game.at(4,3)
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-chess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2
@@ -41,6 +41,7 @@ files:
41
41
  - test/pawn_test.rb
42
42
  - test/queen_test.rb
43
43
  - test/rook_test.rb
44
+ - test/undo_test.rb
44
45
  homepage: https://github.com/jphager2/chess
45
46
  licenses:
46
47
  - MIT