bare_gato 0.0.1 → 0.0.2

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bare_gato (0.0.1)
4
+ bare_gato (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -11,8 +11,8 @@ module BareGato
11
11
  @players = args[:players]
12
12
  end
13
13
 
14
- def add_player player
15
- @players << player
14
+ def includes_player? player
15
+ @players.include? player
16
16
  end
17
17
 
18
18
  def got_a_winner?
@@ -1,3 +1,3 @@
1
1
  module BareGato
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -6,7 +6,7 @@ describe BareGato::Game do
6
6
 
7
7
  let(:o_player) { Player.new 'o' }
8
8
 
9
- describe "a 3x3 game" do
9
+ describe 'a 3x3 game' do
10
10
  subject do
11
11
  bare_gato_game = BareGato::Game.new players: [
12
12
  x_player, o_player
@@ -20,17 +20,23 @@ describe BareGato::Game do
20
20
  bare_gato_game
21
21
  end
22
22
 
23
- it "should start with the last added player" do
23
+ it 'should tell if a player belongs to a game' do
24
+ expect(subject.includes_player? x_player).to be_true
25
+ expect(subject.includes_player? o_player).to be_true
26
+ expect(subject.includes_player? Player.new 'pepino').to be_false
27
+ end
28
+
29
+ it 'should start with the last added player' do
24
30
  expect(subject.next? o_player).to be_true
25
31
  move = Move.new o_player, x: 0, y: 0
26
32
  subject.play move
27
33
  end
28
34
 
29
- it "should return the next move type" do
35
+ it 'should return the next move type' do
30
36
  subject.next.should eq(o_player)
31
37
  end
32
38
 
33
- it "should keep movements sequence" do
39
+ it 'should keep movements sequence' do
34
40
  subject.play Move.new(o_player, x: 0, y: 0)
35
41
  expect(subject.next? o_player).to be_false
36
42
  expect(subject.next? x_player).to be_true
@@ -40,7 +46,7 @@ describe BareGato::Game do
40
46
  expect(subject.next? o_player).to be_true
41
47
  end
42
48
 
43
- it "should return the current game status" do
49
+ it 'should return the current game status' do
44
50
  subject.status.should eq({
45
51
  game: [[nil, nil, nil],
46
52
  [nil, nil, nil],
@@ -49,16 +55,16 @@ describe BareGato::Game do
49
55
  })
50
56
  end
51
57
 
52
- describe "playing a few moves" do
58
+ describe 'playing a few moves' do
53
59
 
54
- context "providing correct moves order" do
60
+ context 'providing correct moves order' do
55
61
  before do
56
62
  subject.play Move.new(o_player, x: 0, y: 0)
57
63
  subject.play Move.new(x_player, x: 1, y: 0)
58
64
  subject.play Move.new(o_player, x: 0, y: 2)
59
65
  end
60
66
 
61
- it "should return the current game status" do
67
+ it 'should return the current game status' do
62
68
  subject.status.should eq({
63
69
  game: [[o_player, x_player, nil],
64
70
  [nil, nil, nil],
@@ -68,8 +74,8 @@ describe BareGato::Game do
68
74
  end
69
75
  end
70
76
 
71
- context "providing incorrect moves order" do
72
- it "should raise error" do
77
+ context 'providing incorrect moves order' do
78
+ it 'should raise error' do
73
79
  expect { subject.play Move.new(x_player, x: 0, y: 0) }.to raise_error
74
80
  subject.play Move.new(o_player, x: 0, y: 0)
75
81
  subject.status.should eq({
@@ -82,9 +88,9 @@ describe BareGato::Game do
82
88
  end
83
89
  end
84
90
 
85
- context "a full game" do
86
- context "when winning by column" do
87
- it "should determine a winner" do
91
+ context 'a full game' do
92
+ context 'when winning by column' do
93
+ it 'should determine a winner' do
88
94
  subject.play Move.new(o_player, x: 0, y: 0)
89
95
  subject.got_a_winner?.should be_false
90
96
 
@@ -111,8 +117,8 @@ describe BareGato::Game do
111
117
  end
112
118
  end
113
119
 
114
- context "when winning by row" do
115
- it "should determine a winner" do
120
+ context 'when winning by row' do
121
+ it 'should determine a winner' do
116
122
  subject.play Move.new(o_player, x: 0, y: 0)
117
123
  subject.got_a_winner?.should be_false
118
124
 
@@ -136,8 +142,8 @@ describe BareGato::Game do
136
142
  end
137
143
  end
138
144
 
139
- context "when winning by diagonal" do
140
- it "should determine a winner" do
145
+ context 'when winning by diagonal' do
146
+ it 'should determine a winner' do
141
147
  subject.play Move.new(o_player, x: 0, y: 0)
142
148
  subject.got_a_winner?.should be_false
143
149
 
@@ -161,8 +167,8 @@ describe BareGato::Game do
161
167
  end
162
168
  end
163
169
 
164
- context "when winning by inverse diagonal" do
165
- it "should determine a winner" do
170
+ context 'when winning by inverse diagonal' do
171
+ it 'should determine a winner' do
166
172
  subject.play Move.new(o_player, x: 2, y: 0)
167
173
  subject.got_a_winner?.should be_false
168
174
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bare_gato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  segments:
108
108
  - 0
109
- hash: -2920284401328294361
109
+ hash: 85962428890766304
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  none: false
112
112
  requirements:
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  segments:
117
117
  - 0
118
- hash: -2920284401328294361
118
+ hash: 85962428890766304
119
119
  requirements: []
120
120
  rubyforge_project:
121
121
  rubygems_version: 1.8.23