rubywarrior 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/{CHANGELOG.rdoc → CHANGELOG.md} +11 -4
  3. data/Gemfile +4 -2
  4. data/Gemfile.lock +44 -25
  5. data/LICENSE +4 -4
  6. data/{README.rdoc → README.md} +115 -93
  7. data/bin/rubywarrior +1 -1
  8. data/features/step_definitions/common_steps.rb +2 -2
  9. data/features/step_definitions/interaction_steps.rb +2 -2
  10. data/lib/ruby_warrior/game.rb +4 -2
  11. data/lib/ruby_warrior/player_generator.rb +2 -2
  12. data/rubywarrior.gemspec +16 -0
  13. data/spec/ruby_warrior/abilities/attack_spec.rb +9 -9
  14. data/spec/ruby_warrior/abilities/base_spec.rb +18 -18
  15. data/spec/ruby_warrior/abilities/bind_spec.rb +4 -4
  16. data/spec/ruby_warrior/abilities/direction_of_spec.rb +2 -2
  17. data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +2 -2
  18. data/spec/ruby_warrior/abilities/distance_of_spec.rb +2 -2
  19. data/spec/ruby_warrior/abilities/explode_spec.rb +6 -6
  20. data/spec/ruby_warrior/abilities/form_spec.rb +13 -13
  21. data/spec/ruby_warrior/abilities/health_spec.rb +2 -2
  22. data/spec/ruby_warrior/abilities/listen_spec.rb +2 -2
  23. data/spec/ruby_warrior/abilities/look_spec.rb +2 -2
  24. data/spec/ruby_warrior/abilities/rescue_spec.rb +7 -7
  25. data/spec/ruby_warrior/abilities/rest_spec.rb +6 -6
  26. data/spec/ruby_warrior/abilities/shoot_spec.rb +3 -3
  27. data/spec/ruby_warrior/abilities/throw_spec.rb +9 -9
  28. data/spec/ruby_warrior/abilities/walk_spec.rb +4 -4
  29. data/spec/ruby_warrior/core_additions_spec.rb +1 -1
  30. data/spec/ruby_warrior/floor_spec.rb +26 -26
  31. data/spec/ruby_warrior/game_spec.rb +34 -34
  32. data/spec/ruby_warrior/level_loader_spec.rb +18 -18
  33. data/spec/ruby_warrior/level_spec.rb +56 -56
  34. data/spec/ruby_warrior/player_generator_spec.rb +2 -2
  35. data/spec/ruby_warrior/position_spec.rb +42 -42
  36. data/spec/ruby_warrior/profile_spec.rb +57 -57
  37. data/spec/ruby_warrior/space_spec.rb +70 -70
  38. data/spec/ruby_warrior/tower_spec.rb +4 -4
  39. data/spec/ruby_warrior/turn_spec.rb +12 -12
  40. data/spec/ruby_warrior/ui_spec.rb +31 -31
  41. data/spec/ruby_warrior/units/archer_spec.rb +8 -8
  42. data/spec/ruby_warrior/units/base_spec.rb +41 -41
  43. data/spec/ruby_warrior/units/captive_spec.rb +8 -8
  44. data/spec/ruby_warrior/units/golem_spec.rb +8 -8
  45. data/spec/ruby_warrior/units/sludge_spec.rb +10 -10
  46. data/spec/ruby_warrior/units/thick_sludge_spec.rb +6 -6
  47. data/spec/ruby_warrior/units/warrior_spec.rb +22 -22
  48. data/spec/ruby_warrior/units/wizard_spec.rb +8 -8
  49. data/spec/spec_helper.rb +1 -0
  50. metadata +32 -33
@@ -4,55 +4,55 @@ describe RubyWarrior::Game do
4
4
  before(:each) do
5
5
  @game = RubyWarrior::Game.new
6
6
  end
7
-
7
+
8
8
  # GAME DIR
9
-
9
+
10
10
  it "should make game directory if player says so" do
11
11
  RubyWarrior::UI.stubs(:ask).returns(true)
12
12
  Dir.expects(:mkdir).with('./rubywarrior')
13
13
  @game.make_game_directory
14
14
  end
15
-
15
+
16
16
  it "should not make game and exit if player says no" do
17
17
  RubyWarrior::UI.stubs(:ask).returns(false)
18
18
  Dir.stubs(:mkdir).raises('should not be called')
19
- lambda { @game.make_game_directory }.should raise_error(SystemExit)
19
+ expect { @game.make_game_directory }.to raise_error(SystemExit)
20
20
  end
21
-
22
-
21
+
22
+
23
23
  # PROFILES
24
-
24
+
25
25
  it "should load profiles for each profile path" do
26
26
  RubyWarrior::Profile.expects(:load).with('foo/.profile').returns(1)
27
27
  RubyWarrior::Profile.expects(:load).with('bar/.profile').returns(2)
28
28
  @game.stubs(:profile_paths).returns(['foo/.profile', 'bar/.profile'])
29
- @game.profiles.should == [1, 2]
29
+ expect(@game.profiles).to eq([1, 2])
30
30
  end
31
-
31
+
32
32
  it "should find profile paths using Dir[] search" do
33
33
  Dir.expects(:[]).with("./rubywarrior/**/.profile")
34
34
  @game.profile_paths
35
35
  end
36
-
36
+
37
37
  it "should try to create profile when no profile paths are specified" do
38
38
  @game.stubs(:profiles).returns([])
39
39
  @game.expects(:new_profile).returns('profile')
40
- @game.profile.should == 'profile'
40
+ expect(@game.profile).to eq('profile')
41
41
  end
42
-
42
+
43
43
  it "should ask a player to choose a profile if multiple profiles are available, but only once" do
44
44
  RubyWarrior::UI.expects(:choose).with('profile', [:profile1, [:new, 'New Profile']]).returns(:profile1)
45
45
  @game.stubs(:profiles).returns([:profile1])
46
- 2.times { @game.profile.should == :profile1 }
46
+ 2.times { expect(@game.profile).to eq(:profile1) }
47
47
  end
48
-
48
+
49
49
  it "should ask user to choose a tower when creating a new profile" do
50
50
  RubyWarrior::UI.stubs(:gets).returns('')
51
51
  @game.stubs(:towers).returns([:tower1, :tower2])
52
52
  RubyWarrior::UI.expects(:choose).with('tower', [:tower1, :tower2]).returns(stub(:path => '/foo/bar'))
53
53
  @game.new_profile
54
54
  end
55
-
55
+
56
56
  it "should pass name and selected tower to profile" do
57
57
  profile = stub
58
58
  RubyWarrior::UI.stubs(:choose).returns(stub(:path => 'tower_path'))
@@ -60,60 +60,60 @@ describe RubyWarrior::Game do
60
60
  RubyWarrior::Profile.expects(:new).returns(profile)
61
61
  profile.expects(:tower_path=).with('tower_path')
62
62
  profile.expects(:warrior_name=).with('name')
63
- @game.new_profile.should == profile
63
+ expect(@game.new_profile).to eq(profile)
64
64
  end
65
-
66
-
65
+
66
+
67
67
  # TOWERS
68
-
68
+
69
69
  it "load towers for each tower path" do
70
70
  RubyWarrior::Tower.expects(:new).with('towers/foo').returns(1)
71
71
  RubyWarrior::Tower.expects(:new).with('towers/bar').returns(2)
72
72
  @game.stubs(:tower_paths).returns(['towers/foo', 'towers/bar'])
73
- @game.towers.should == [1, 2]
73
+ expect(@game.towers).to eq([1, 2])
74
74
  end
75
-
75
+
76
76
  it "should find tower paths using Dir[] search" do
77
77
  Dir.expects(:[]).with(File.expand_path('../../../towers/*', __FILE__))
78
78
  @game.tower_paths
79
79
  end
80
-
81
-
80
+
81
+
82
82
  # LEVEL
83
-
83
+
84
84
  it "should fetch current level from profile and cache it" do
85
85
  @game.stubs(:profile).returns(stub)
86
86
  @game.profile.expects(:current_level).returns('foo')
87
- 2.times { @game.current_level.should == 'foo' }
87
+ 2.times { expect(@game.current_level).to eq('foo') }
88
88
  end
89
-
89
+
90
90
  it "should fetch next level from profile and cache it" do
91
91
  @game.stubs(:profile).returns(stub)
92
92
  @game.profile.expects(:next_level).returns('bar')
93
- 2.times { @game.next_level.should == 'bar' }
93
+ 2.times { expect(@game.next_level).to eq('bar') }
94
94
  end
95
-
95
+
96
96
  it "should report final grade" do
97
97
  profile = RubyWarrior::Profile.new
98
98
  profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
99
99
  @game.stubs(:profile).returns(profile)
100
100
  report = @game.final_report
101
- report.should include("Your average grade for this tower is: B")
102
- report.should include("Level 1: C\n Level 2: A")
101
+ expect(report).to include("Your average grade for this tower is: B")
102
+ expect(report).to include("Level 1: C\n Level 2: A")
103
103
  end
104
-
104
+
105
105
  it "should have an empty final report if no epic grades are available" do
106
106
  profile = RubyWarrior::Profile.new
107
107
  profile.current_epic_grades = {}
108
108
  @game.stubs(:profile).returns(profile)
109
- @game.final_report.should be_nil
109
+ expect(@game.final_report).to be_nil
110
110
  end
111
-
111
+
112
112
  it "should have an empty final report if practice level" do
113
113
  RubyWarrior::Config.practice_level = 2
114
114
  profile = RubyWarrior::Profile.new
115
115
  profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
116
116
  @game.stubs(:profile).returns(profile)
117
- @game.final_report.should be_nil
117
+ expect(@game.final_report).to be_nil
118
118
  end
119
119
  end
@@ -7,48 +7,48 @@ describe RubyWarrior::LevelLoader do
7
7
  @level = RubyWarrior::Level.new(@profile, 1)
8
8
  @loader = RubyWarrior::LevelLoader.new(@level)
9
9
  end
10
-
10
+
11
11
  it "should be able to add description, tip and clue" do
12
12
  @loader.description "foo"
13
13
  @loader.tip "bar"
14
14
  @loader.clue "clue"
15
- @level.description.should == "foo"
16
- @level.tip.should == "bar"
17
- @level.clue.should == "clue"
15
+ expect(@level.description).to eq("foo")
16
+ expect(@level.tip).to eq("bar")
17
+ expect(@level.clue).to eq("clue")
18
18
  end
19
-
19
+
20
20
  it "should be able to set size" do
21
21
  @loader.size 5, 3
22
- @level.floor.width.should == 5
23
- @level.floor.height.should == 3
22
+ expect(@level.floor.width).to eq(5)
23
+ expect(@level.floor.height).to eq(3)
24
24
  end
25
-
25
+
26
26
  it "should be able to add stairs" do
27
27
  @level.floor.expects(:place_stairs).with(1, 2)
28
28
  @loader.stairs 1, 2
29
29
  end
30
-
30
+
31
31
  it "should yield new unit when building" do
32
32
  @loader.unit :base, 1, 2 do |unit|
33
- unit.should be_kind_of(RubyWarrior::Units::Base)
34
- unit.position.should be_at(1, 2)
33
+ expect(unit).to be_kind_of(RubyWarrior::Units::Base)
34
+ expect(unit.position).to be_at(1, 2)
35
35
  end
36
36
  end
37
-
37
+
38
38
  it "should be able to add multi-word units" do
39
- lambda { @loader.unit :thick_sludge, 1, 2 }.should_not raise_error
39
+ expect { @loader.unit :thick_sludge, 1, 2 }.to_not raise_error
40
40
  end
41
-
41
+
42
42
  it "should build warrior from profile" do
43
43
  @loader.warrior 1, 2 do |unit|
44
- unit.should be_kind_of(RubyWarrior::Units::Warrior)
45
- unit.position.should be_at(1, 2)
44
+ expect(unit).to be_kind_of(RubyWarrior::Units::Warrior)
45
+ expect(unit.position).to be_at(1, 2)
46
46
  end
47
47
  end
48
-
48
+
49
49
  it "should be able to set time bonus" do
50
50
  @loader.time_bonus 100
51
- @level.time_bonus.should == 100
51
+ expect(@level.time_bonus).to eq(100)
52
52
  end
53
53
  end
54
54
  end
@@ -9,64 +9,64 @@ describe RubyWarrior::Level do
9
9
  @level.floor = @floor
10
10
  @level.stubs(:failed?).returns(false)
11
11
  end
12
-
12
+
13
13
  it "should consider passed when warrior is on stairs" do
14
14
  @level.warrior = RubyWarrior::Units::Warrior.new
15
15
  @floor.add(@level.warrior, 0, 0, :north)
16
16
  @floor.place_stairs(0, 0)
17
- @level.should be_passed
17
+ expect(@level).to be_passed
18
18
  end
19
-
19
+
20
20
  it "should default time bonus to zero" do
21
- @level.time_bonus.should be_zero
21
+ expect(@level.time_bonus).to be_zero
22
22
  end
23
-
23
+
24
24
  it "should have a grade relative to ace score" do
25
25
  @level.ace_score = 100
26
- @level.grade_for(110).should == "S"
27
- @level.grade_for(100).should == "S"
28
- @level.grade_for(99).should == "A"
29
- @level.grade_for(89).should == "B"
30
- @level.grade_for(79).should == "C"
31
- @level.grade_for(69).should == "D"
32
- @level.grade_for(59).should == "F"
26
+ expect(@level.grade_for(110)).to eq("S")
27
+ expect(@level.grade_for(100)).to eq("S")
28
+ expect(@level.grade_for(99)).to eq("A")
29
+ expect(@level.grade_for(89)).to eq("B")
30
+ expect(@level.grade_for(79)).to eq("C")
31
+ expect(@level.grade_for(69)).to eq("D")
32
+ expect(@level.grade_for(59)).to eq("F")
33
33
  end
34
-
34
+
35
35
  it "should have no grade if there is no ace score" do
36
- @level.ace_score.should be_nil
37
- @level.grade_for(100).should be_nil
36
+ expect(@level.ace_score).to be_nil
37
+ expect(@level.grade_for(100)).to be_nil
38
38
  end
39
-
39
+
40
40
  it "should load file contents into level" do
41
41
  @level.stubs(:load_path).returns('path/to/level.rb')
42
42
  File.expects(:read).with('path/to/level.rb').returns("description 'foo'")
43
43
  @level.load_level
44
- @level.description.should == 'foo'
44
+ expect(@level.description).to eq('foo')
45
45
  end
46
-
46
+
47
47
  it "should have a player path from profile" do
48
48
  @profile.stubs(:player_path).returns('path/to/player')
49
- @level.player_path.should == 'path/to/player'
49
+ expect(@level.player_path).to eq('path/to/player')
50
50
  end
51
-
51
+
52
52
  it "should have a load path from profile tower with level number in it" do
53
53
  @profile.stubs(:tower_path).returns('path/to/tower')
54
- @level.load_path.should == File.expand_path('towers/tower/level_001.rb')
54
+ expect(@level.load_path).to eq(File.expand_path('towers/tower/level_001.rb'))
55
55
  end
56
-
56
+
57
57
  it "should exist if file exists" do
58
58
  @level.stubs(:load_path).returns('/foo/bar')
59
59
  File.expects(:exist?).with('/foo/bar').returns(true)
60
- @level.exists?.should be_true
60
+ expect(@level.exists?).to eq(true)
61
61
  end
62
-
62
+
63
63
  it "should load player and player path" do
64
64
  @level.stubs(:player_path).returns('player/path')
65
65
  $:.expects(:<<).with('player/path')
66
66
  @level.expects(:load).with('player.rb')
67
67
  @level.load_player
68
68
  end
69
-
69
+
70
70
  it "should generate player files" do
71
71
  @level.expects(:load_level)
72
72
  generator = stub
@@ -74,31 +74,31 @@ describe RubyWarrior::Level do
74
74
  RubyWarrior::PlayerGenerator.expects(:new).with(@level).returns(generator)
75
75
  @level.generate_player_files
76
76
  end
77
-
77
+
78
78
  it "should setup warrior with profile abilities" do
79
79
  @profile.abilities = [:foo, :bar]
80
80
  warrior = stub_everything
81
81
  warrior.expects(:add_abilities).with(:foo, :bar)
82
82
  @level.setup_warrior(warrior)
83
83
  end
84
-
84
+
85
85
  it "should setup warrior with profile name" do
86
86
  @profile.warrior_name = "Joe"
87
87
  warrior = stub_everything
88
88
  warrior.expects(:name=).with("Joe")
89
89
  @level.setup_warrior(warrior)
90
90
  end
91
-
91
+
92
92
  describe "playing" do
93
93
  before(:each) do
94
94
  @level.stubs(:load_level)
95
95
  end
96
-
96
+
97
97
  it "should load level once when playing multiple turns" do
98
98
  @level.expects(:load_level)
99
99
  @level.play(2)
100
100
  end
101
-
101
+
102
102
  it "should call prepare_turn and play_turn on each object specified number of times" do
103
103
  object = RubyWarrior::Units::Base.new
104
104
  object.expects(:prepare_turn).times(2)
@@ -106,7 +106,7 @@ describe RubyWarrior::Level do
106
106
  @floor.add(object, 0, 0, :north)
107
107
  @level.play(2)
108
108
  end
109
-
109
+
110
110
  it "should return immediately when passed" do
111
111
  object = RubyWarrior::Units::Base.new
112
112
  object.expects(:turn).times(0)
@@ -114,90 +114,90 @@ describe RubyWarrior::Level do
114
114
  @level.stubs(:passed?).returns(true)
115
115
  @level.play(2)
116
116
  end
117
-
117
+
118
118
  it "should yield to block in play method for each turn" do
119
119
  int = 0
120
120
  @level.play(2) do
121
121
  int += 1
122
122
  end
123
- int.should == 2
123
+ expect(int).to eq(2)
124
124
  end
125
-
125
+
126
126
  it "should count down time_bonus once each turn" do
127
127
  @level.time_bonus = 10
128
128
  @level.play(3)
129
- @level.time_bonus.should == 7
129
+ expect(@level.time_bonus).to eq(7)
130
130
  end
131
-
131
+
132
132
  it "should count down time_bonus below 0" do
133
133
  @level.time_bonus = 2
134
134
  @level.play(5)
135
- @level.time_bonus.should be_zero
135
+ expect(@level.time_bonus).to be_zero
136
136
  end
137
-
137
+
138
138
  it "should have a pretty score calculation" do
139
- @level.score_calculation(123, 45).should == "123 + 45 = 168"
139
+ expect(@level.score_calculation(123, 45)).to eq("123 + 45 = 168")
140
140
  end
141
-
141
+
142
142
  it "should not have a score calculation when starting score is zero" do
143
- @level.score_calculation(0, 45).should == "45"
143
+ expect(@level.score_calculation(0, 45)).to eq("45")
144
144
  end
145
145
  end
146
-
146
+
147
147
  describe "tallying points" do
148
148
  before(:each) do
149
149
  @warrior = stub(:score => 0, :abilities => {})
150
150
  @level.stubs(:warrior).returns(@warrior)
151
151
  @level.floor.stubs(:other_units).returns([stub])
152
152
  end
153
-
153
+
154
154
  it "should add warrior score to profile" do
155
155
  @warrior.stubs(:score).returns(30)
156
156
  @level.tally_points
157
- @profile.score.should == 30
157
+ expect(@profile.score).to eq(30)
158
158
  end
159
-
159
+
160
160
  it "should add warrior score to profile for epic mode" do
161
161
  @profile.enable_epic_mode
162
162
  @warrior.stubs(:score).returns(30)
163
163
  @level.tally_points
164
- @profile.current_epic_score.should == 30
164
+ expect(@profile.current_epic_score).to eq(30)
165
165
  end
166
-
166
+
167
167
  it "should add level grade percent to profile for epic mode" do
168
168
  @level.ace_score = 100
169
169
  @profile.enable_epic_mode
170
170
  @warrior.stubs(:score).returns(30)
171
171
  @level.tally_points
172
- @profile.current_epic_grades.should == { 1 => 0.3 }
172
+ expect(@profile.current_epic_grades).to eq({ 1 => 0.3 })
173
173
  end
174
-
174
+
175
175
  it "should not add level grade if ace score is not set" do
176
176
  @level.ace_score = nil
177
177
  @profile.enable_epic_mode
178
178
  @warrior.stubs(:score).returns(30)
179
179
  @level.tally_points
180
- @profile.current_epic_grades.should == {}
180
+ expect(@profile.current_epic_grades).to eq({})
181
181
  end
182
-
182
+
183
183
  it "should apply warrior abilities to profile" do
184
184
  @warrior.stubs(:abilities).returns({:foo => nil, :bar => nil})
185
185
  @level.tally_points
186
- @profile.abilities.to_set.should == [:foo, :bar].to_set
186
+ expect(@profile.abilities.to_set).to eq([:foo, :bar].to_set)
187
187
  end
188
-
188
+
189
189
  it "should apply time bonus to profile score" do
190
190
  @level.time_bonus = 20
191
191
  @level.tally_points
192
- @profile.score.should == 20
192
+ expect(@profile.score).to eq(20)
193
193
  end
194
-
194
+
195
195
  it "should give 20% bonus when no other units left" do
196
196
  @level.floor.stubs(:other_units).returns([])
197
197
  @warrior.stubs(:score).returns(10)
198
198
  @level.time_bonus = 10
199
199
  @level.tally_points
200
- @profile.score.should == 24
200
+ expect(@profile.score).to eq(24)
201
201
  end
202
202
  end
203
203
  end
@@ -5,8 +5,8 @@ describe RubyWarrior::PlayerGenerator do
5
5
  @level = RubyWarrior::Level.new(RubyWarrior::Profile.new, 15)
6
6
  @generator = RubyWarrior::PlayerGenerator.new(@level)
7
7
  end
8
-
8
+
9
9
  it "should know templates path" do
10
- @generator.templates_path.should == File.expand_path("../../../templates", __FILE__)
10
+ expect(@generator.templates_path).to eq(File.expand_path("../../../templates", __FILE__))
11
11
  end
12
12
  end
@@ -9,100 +9,100 @@ describe RubyWarrior::Position do
9
9
  @floor.add(@unit, 1, 2, :north)
10
10
  @position = @unit.position
11
11
  end
12
-
12
+
13
13
  it "should rotate clockwise" do
14
- @position.direction.should == :north
14
+ expect(@position.direction).to eq(:north)
15
15
  [:east, :south, :west, :north, :east].each do |dir|
16
16
  @position.rotate(1)
17
- @position.direction.should == dir
17
+ expect(@position.direction).to eq(dir)
18
18
  end
19
19
  end
20
-
20
+
21
21
  it "should rotate counterclockwise" do
22
- @position.direction.should == :north
22
+ expect(@position.direction).to eq(:north)
23
23
  [:west, :south, :east, :north, :west].each do |dir|
24
24
  @position.rotate(-1)
25
- @position.direction.should == dir
25
+ expect(@position.direction).to eq(dir)
26
26
  end
27
27
  end
28
-
28
+
29
29
  it "should get relative space in front" do
30
30
  unit = RubyWarrior::Units::Base.new
31
31
  @floor.add(unit, 1, 1)
32
- @position.relative_space(1).should_not be_empty
32
+ expect(@position.relative_space(1)).to_not be_empty
33
33
  end
34
-
34
+
35
35
  it "should get relative object in front when rotated" do
36
36
  unit = RubyWarrior::Units::Base.new
37
37
  @floor.add(unit, 2, 2)
38
38
  @position.rotate(1)
39
- @position.relative_space(1).should_not be_empty
39
+ expect(@position.relative_space(1)).to_not be_empty
40
40
  end
41
-
41
+
42
42
  it "should get relative object diagonally" do
43
43
  unit = RubyWarrior::Units::Base.new
44
44
  @floor.add(unit, 0, 1)
45
- @position.relative_space(1, -1).should_not be_empty
45
+ expect(@position.relative_space(1, -1)).to_not be_empty
46
46
  end
47
-
47
+
48
48
  it "should get relative object diagonally when rotating" do
49
49
  unit = RubyWarrior::Units::Base.new
50
50
  @floor.add(unit, 0, 1)
51
51
  @position.rotate(2)
52
- @position.relative_space(-1, 1).should_not be_empty
52
+ expect(@position.relative_space(-1, 1)).to_not be_empty
53
53
  end
54
-
54
+
55
55
  it "should move object on floor relatively" do
56
- @floor.get(1, 2).should == @unit
56
+ expect(@floor.get(1, 2)).to eq(@unit)
57
57
  @position.move(-1, 2)
58
- @floor.get(1, 2).should be_nil
59
- @floor.get(3, 3).should == @unit
58
+ expect(@floor.get(1, 2)).to be_nil
59
+ expect(@floor.get(3, 3)).to eq(@unit)
60
60
  @position.rotate(1)
61
61
  @position.move(-1)
62
- @floor.get(3, 3).should be_nil
63
- @floor.get(2, 3).should == @unit
62
+ expect(@floor.get(3, 3)).to be_nil
63
+ expect(@floor.get(2, 3)).to eq(@unit)
64
64
  end
65
-
65
+
66
66
  it "should return distance from stairs as 0 when on stairs" do
67
67
  @floor.place_stairs(1, 2)
68
- @position.distance_from_stairs.should == 0
68
+ expect(@position.distance_from_stairs).to eq(0)
69
69
  end
70
-
70
+
71
71
  it "should return distance from stairs in both directions" do
72
72
  @floor.place_stairs(0, 3)
73
- @position.distance_from_stairs.should == 2
73
+ expect(@position.distance_from_stairs).to eq(2)
74
74
  end
75
-
75
+
76
76
  it "should return relative direction of stairs" do
77
77
  @floor.place_stairs(0, 0)
78
- @position.relative_direction_of_stairs.should == :forward
78
+ expect(@position.relative_direction_of_stairs).to eq(:forward)
79
79
  end
80
-
80
+
81
81
  it "should return relative direction of given space" do
82
- @position.relative_direction_of(@floor.space(5, 3)).should == :right
82
+ expect(@position.relative_direction_of(@floor.space(5, 3))).to eq(:right)
83
83
  @position.rotate 1
84
- @position.relative_direction_of(@floor.space(1, 4)).should == :right
84
+ expect(@position.relative_direction_of(@floor.space(1, 4))).to eq(:right)
85
85
  end
86
-
86
+
87
87
  it "should be able to determine relative direction" do
88
- @position.relative_direction(:north).should == :forward
89
- @position.relative_direction(:south).should == :backward
90
- @position.relative_direction(:west).should == :left
91
- @position.relative_direction(:east).should == :right
88
+ expect(@position.relative_direction(:north)).to eq(:forward)
89
+ expect(@position.relative_direction(:south)).to eq(:backward)
90
+ expect(@position.relative_direction(:west)).to eq(:left)
91
+ expect(@position.relative_direction(:east)).to eq(:right)
92
92
  @position.rotate 1
93
- @position.relative_direction(:north).should == :left
93
+ expect(@position.relative_direction(:north)).to eq(:left)
94
94
  @position.rotate 1
95
- @position.relative_direction(:north).should == :backward
95
+ expect(@position.relative_direction(:north)).to eq(:backward)
96
96
  @position.rotate 1
97
- @position.relative_direction(:north).should == :right
97
+ expect(@position.relative_direction(:north)).to eq(:right)
98
98
  end
99
-
99
+
100
100
  it "should return a space at the same location as position" do
101
- @position.space.location.should == [1, 2]
101
+ expect(@position.space.location).to eq([1, 2])
102
102
  end
103
-
103
+
104
104
  it "should return distance of given space" do
105
- @position.distance_of(@floor.space(5, 3)).should == 5
106
- @position.distance_of(@floor.space(4, 2)).should == 3
105
+ expect(@position.distance_of(@floor.space(5, 3))).to eq(5)
106
+ expect(@position.distance_of(@floor.space(4, 2))).to eq(3)
107
107
  end
108
108
  end