rubywarrior 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/{CHANGELOG.rdoc → CHANGELOG.md} +21 -3
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +55 -0
  5. data/LICENSE +4 -4
  6. data/{README.rdoc → README.md} +115 -93
  7. data/Rakefile +4 -9
  8. data/bin/rubywarrior +1 -1
  9. data/features/step_definitions/common_steps.rb +2 -2
  10. data/features/step_definitions/interaction_steps.rb +7 -7
  11. data/features/support/env.rb +1 -1
  12. data/lib/ruby_warrior/game.rb +5 -3
  13. data/lib/ruby_warrior/level.rb +5 -1
  14. data/lib/ruby_warrior/player_generator.rb +3 -3
  15. data/lib/ruby_warrior/profile.rb +1 -1
  16. data/lib/ruby_warrior/tower.rb +1 -1
  17. data/rubywarrior.gemspec +16 -0
  18. data/spec/ruby_warrior/abilities/attack_spec.rb +10 -10
  19. data/spec/ruby_warrior/abilities/base_spec.rb +19 -19
  20. data/spec/ruby_warrior/abilities/bind_spec.rb +5 -5
  21. data/spec/ruby_warrior/abilities/direction_of_spec.rb +3 -3
  22. data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +3 -3
  23. data/spec/ruby_warrior/abilities/distance_of_spec.rb +3 -3
  24. data/spec/ruby_warrior/abilities/explode_spec.rb +7 -7
  25. data/spec/ruby_warrior/abilities/feel_spec.rb +1 -1
  26. data/spec/ruby_warrior/abilities/form_spec.rb +14 -14
  27. data/spec/ruby_warrior/abilities/health_spec.rb +3 -3
  28. data/spec/ruby_warrior/abilities/listen_spec.rb +3 -3
  29. data/spec/ruby_warrior/abilities/look_spec.rb +3 -3
  30. data/spec/ruby_warrior/abilities/pivot_spec.rb +1 -1
  31. data/spec/ruby_warrior/abilities/rescue_spec.rb +8 -8
  32. data/spec/ruby_warrior/abilities/rest_spec.rb +7 -7
  33. data/spec/ruby_warrior/abilities/shoot_spec.rb +4 -4
  34. data/spec/ruby_warrior/abilities/throw_spec.rb +10 -10
  35. data/spec/ruby_warrior/abilities/walk_spec.rb +5 -5
  36. data/spec/ruby_warrior/core_additions_spec.rb +2 -2
  37. data/spec/ruby_warrior/floor_spec.rb +27 -27
  38. data/spec/ruby_warrior/game_spec.rb +36 -36
  39. data/spec/ruby_warrior/level_loader_spec.rb +19 -19
  40. data/spec/ruby_warrior/level_spec.rb +57 -57
  41. data/spec/ruby_warrior/player_generator_spec.rb +3 -3
  42. data/spec/ruby_warrior/position_spec.rb +43 -43
  43. data/spec/ruby_warrior/profile_spec.rb +59 -59
  44. data/spec/ruby_warrior/space_spec.rb +71 -71
  45. data/spec/ruby_warrior/tower_spec.rb +5 -5
  46. data/spec/ruby_warrior/turn_spec.rb +13 -13
  47. data/spec/ruby_warrior/ui_spec.rb +32 -32
  48. data/spec/ruby_warrior/units/archer_spec.rb +9 -9
  49. data/spec/ruby_warrior/units/base_spec.rb +42 -42
  50. data/spec/ruby_warrior/units/captive_spec.rb +9 -9
  51. data/spec/ruby_warrior/units/golem_spec.rb +9 -9
  52. data/spec/ruby_warrior/units/sludge_spec.rb +11 -11
  53. data/spec/ruby_warrior/units/thick_sludge_spec.rb +7 -7
  54. data/spec/ruby_warrior/units/warrior_spec.rb +23 -23
  55. data/spec/ruby_warrior/units/wizard_spec.rb +9 -9
  56. data/spec/spec_helper.rb +3 -2
  57. data/towers/beginner/level_002.rb +1 -1
  58. data/towers/beginner/level_003.rb +1 -1
  59. data/towers/beginner/level_005.rb +2 -2
  60. data/towers/beginner/level_006.rb +2 -2
  61. data/towers/intermediate/level_002.rb +1 -1
  62. data/towers/intermediate/level_003.rb +2 -2
  63. metadata +47 -67
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe RubyWarrior::Floor do
4
4
  describe "2x3" do
@@ -7,75 +7,75 @@ describe RubyWarrior::Floor do
7
7
  @floor.width = 2
8
8
  @floor.height = 3
9
9
  end
10
-
10
+
11
11
  it "should be able to add a unit and fetch it at that position" do
12
12
  unit = RubyWarrior::Units::Base.new
13
13
  @floor.add(unit, 0, 1, :north)
14
- @floor.get(0, 1).should == unit
14
+ expect(@floor.get(0, 1)).to eq(unit)
15
15
  end
16
-
16
+
17
17
  it "should not consider unit on floor if no position" do
18
18
  unit = RubyWarrior::Units::Base.new
19
19
  @floor.add(unit, 0, 1, :north)
20
20
  unit.position = nil
21
- @floor.units.should_not include(unit)
21
+ expect(@floor.units).to_not include(unit)
22
22
  end
23
-
23
+
24
24
  it "should fetch other units not warrior" do
25
25
  unit = RubyWarrior::Units::Base.new
26
26
  warrior = RubyWarrior::Units::Warrior.new
27
27
  @floor.add(unit, 0, 0, :north)
28
28
  @floor.add(warrior, 1, 0, :north)
29
- @floor.other_units.should_not include(warrior)
30
- @floor.other_units.should include(unit)
29
+ expect(@floor.other_units).to_not include(warrior)
30
+ expect(@floor.other_units).to include(unit)
31
31
  end
32
-
32
+
33
33
  it "should not consider corners out of bounds" do
34
- @floor.should_not be_out_of_bounds(0, 0)
35
- @floor.should_not be_out_of_bounds(1, 0)
36
- @floor.should_not be_out_of_bounds(1, 2)
37
- @floor.should_not be_out_of_bounds(0, 2)
34
+ expect(@floor).to_not be_out_of_bounds(0, 0)
35
+ expect(@floor).to_not be_out_of_bounds(1, 0)
36
+ expect(@floor).to_not be_out_of_bounds(1, 2)
37
+ expect(@floor).to_not be_out_of_bounds(0, 2)
38
38
  end
39
-
39
+
40
40
  it "should consider out of bounds when going beyond sides" do
41
- @floor.should be_out_of_bounds(-1, 0)
42
- @floor.should be_out_of_bounds(0, -1)
43
- @floor.should be_out_of_bounds(0, 3)
44
- @floor.should be_out_of_bounds(2, 0)
41
+ expect(@floor).to be_out_of_bounds(-1, 0)
42
+ expect(@floor).to be_out_of_bounds(0, -1)
43
+ expect(@floor).to be_out_of_bounds(0, 3)
44
+ expect(@floor).to be_out_of_bounds(2, 0)
45
45
  end
46
-
46
+
47
47
  it "should return space at the specified location" do
48
- @floor.space(0, 0).should be_kind_of(RubyWarrior::Space)
48
+ expect(@floor.space(0, 0)).to be_kind_of(RubyWarrior::Space)
49
49
  end
50
-
50
+
51
51
  it "should place stairs and be able to fetch the location" do
52
52
  @floor.place_stairs(1, 2)
53
- @floor.stairs_location.should == [1, 2]
53
+ expect(@floor.stairs_location).to eq([1, 2])
54
54
  end
55
55
  end
56
-
56
+
57
57
  describe "3x1" do
58
58
  before(:each) do
59
59
  @floor = RubyWarrior::Floor.new
60
60
  @floor.width = 3
61
61
  @floor.height = 1
62
62
  end
63
-
63
+
64
64
  it "should print map with stairs and unit" do
65
65
  @floor.add(RubyWarrior::Units::Warrior.new, 0, 0)
66
66
  @floor.place_stairs(2, 0)
67
- @floor.character.should == <<-MAP
67
+ expect(@floor.character).to eq(<<-MAP)
68
68
  ---
69
69
  |@ >|
70
70
  ---
71
71
  MAP
72
72
  end
73
-
73
+
74
74
  it "should return unique units" do
75
75
  u1 = RubyWarrior::Units::Base.new
76
76
  @floor.add(u1, 0, 0)
77
77
  @floor.add(RubyWarrior::Units::Base.new, 1, 0)
78
- @floor.unique_units.should == [u1]
78
+ expect(@floor.unique_units).to eq([u1])
79
79
  end
80
80
  end
81
81
  end
@@ -1,58 +1,58 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  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
- Dir.expects(:[]).with(File.expand_path(File.dirname(__FILE__) + '/../../towers/*'))
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
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe RubyWarrior::LevelLoader do
4
4
  describe "with profile" do
@@ -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
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
  require 'set'
3
3
 
4
4
  describe RubyWarrior::Level do
@@ -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 == 'path/to/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
@@ -1,12 +1,12 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe RubyWarrior::PlayerGenerator do
4
4
  before(:each) 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(File.dirname(__FILE__) + "/../../templates")
10
+ expect(@generator.templates_path).to eq(File.expand_path("../../../templates", __FILE__))
11
11
  end
12
12
  end