minesweeper 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/lib/minesweeper/version.rb +1 -1
- metadata +1 -2
- data/README.md +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ba8f9bc591a9dbb7df82eb99942ffa2340fb57
|
4
|
+
data.tar.gz: 23bc36c84d3a6b7d6c291410c87db70415c13b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31822b402b82e4295b1d3ca11b06a34a365d6043fcb44148c2603cd18bd567c4e899a8c39bbe529247a062918a1b470e549d5fabad6cc1c0a09ca6fb6d954518
|
7
|
+
data.tar.gz: ca4477a57293255d7733016212e27bdc3e71be6999780751d121c1a7ab880691909aeb094fc5c830f24fb508f985180e935085512fbc7b794f68b2cf0fed9eb1
|
data/.DS_Store
CHANGED
Binary file
|
data/lib/minesweeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minesweeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Alexander
|
@@ -78,7 +78,6 @@ files:
|
|
78
78
|
- Gemfile
|
79
79
|
- Guardfile
|
80
80
|
- LICENSE.txt
|
81
|
-
- README.md
|
82
81
|
- Rakefile
|
83
82
|
- lib/.DS_Store
|
84
83
|
- lib/minesweeper.rb
|
data/README.md
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
Minesweeper TDD Solution
|
2
|
-
========================
|
3
|
-
|
4
|
-
If you got even most of this project done, you can consider yourself *far* beyond a beginner in Ruby. You're TDDing like the pros, and learning to decompose your methods. Most of all, what you should have learned from this is that smaller and more isolated methods are easier to test, and it's much easier to set up an example than to try to test by absolute logical necessity.
|
5
|
-
|
6
|
-
##Points of Interest
|
7
|
-
|
8
|
-
- the game loop itself is hard to test beyond expecting messages to be sent to certain objects
|
9
|
-
+ make sure to stub out victory conditions so your test doesn't get caught in an infinite loop
|
10
|
-
- the board is where the meat of the logic is, and that's where unit testing is most effective
|
11
|
-
- to test methods like counting adjacent mines, cheat
|
12
|
-
+ use a `before` clause to set mines exactly where you want them
|
13
|
-
+ then run your `#num_adjacent_mines` method
|
14
|
-
- testing automated mine clearing is hard. don't look for the perfect algorithm here
|
15
|
-
+ instead, see if a mine with zero others around it also clears off the 8 mines surrounding it
|
16
|
-
- remember that the `equal` method and the `eq` method in Rspec are not the same
|
17
|
-
+ if something `equal`s `true`, then it literally IS that object
|
18
|
-
+ if it `eq`s `true`, that's normal Ruby Boolean truthiness
|
19
|
-
+ `equal` is VERY useful to make sure boolean methods actually work!
|
20
|
-
-_Bonus:_ when working with 2D arrays, remember you can always use the `#flatten` method to get at the elements inside.
|
21
|
-
- this comes in really handy when you want to compare two 2D arrays for equality or set all their elements equal
|
22
|
-
- `@board.grid.flatten.each {|s| s.mine = false }` is a one-liner to remove every mine from the board, as another example
|
23
|
-
|
24
|
-
|
25
|
-
## A bonus
|
26
|
-
|
27
|
-
You can iteratively generate expectations, even stack them. It's not often the right way to go, but every once in a while it's perfect.
|
28
|
-
|
29
|
-
See here:
|
30
|
-
|
31
|
-
```code-rspec
|
32
|
-
|
33
|
-
context 'if the space has zero mines nearby' do
|
34
|
-
# ...other stuff
|
35
|
-
|
36
|
-
it 'should uncover all adjacent mines' do
|
37
|
-
|
38
|
-
subject.mark_clear(3,3)
|
39
|
-
|
40
|
-
# whoa! you can iterate expectations!
|
41
|
-
# this way, the test fails if any one of these
|
42
|
-
# *NINE* expect clauses fail
|
43
|
-
# which is to say, if any adjacent square remains hidden
|
44
|
-
|
45
|
-
2.upto(4) do |x|
|
46
|
-
2.upto(4) do |y|
|
47
|
-
expect(subject[x][y].visible).to equal true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
```
|
54
|
-
|
55
|
-
*NOTE: This solution repo is copyrighted material for your private use only and not to be shared outside of Viking Code School.*
|