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,80 +4,80 @@ describe RubyWarrior::Profile do
4
4
  before(:each) do
5
5
  @profile = RubyWarrior::Profile.new
6
6
  end
7
-
7
+
8
8
  it "should have warrior name" do
9
9
  @profile.warrior_name = 'Joe'
10
- @profile.warrior_name.should == 'Joe'
10
+ expect(@profile.warrior_name).to eq('Joe')
11
11
  end
12
-
12
+
13
13
  it "should start level number at 0" do
14
- @profile.level_number.should be_zero
14
+ expect(@profile.level_number).to be_zero
15
15
  end
16
-
16
+
17
17
  it "should start score at 0 and allow it to increment" do
18
- @profile.score.should be_zero
18
+ expect(@profile.score).to be_zero
19
19
  @profile.score += 5
20
- @profile.score.should == 5
20
+ expect(@profile.score).to eq(5)
21
21
  end
22
-
22
+
23
23
  it "should have no abilities and allow adding" do
24
- @profile.abilities.should == []
24
+ expect(@profile.abilities).to eq([])
25
25
  @profile.abilities += [:foo, :bar]
26
- @profile.abilities.should == [:foo, :bar]
26
+ expect(@profile.abilities).to eq([:foo, :bar])
27
27
  end
28
-
28
+
29
29
  it "should encode with marshal + base64" do
30
- @profile.encode.should == Base64.encode64(Marshal.dump(@profile))
30
+ expect(@profile.encode).to eq(Base64.encode64(Marshal.dump(@profile)))
31
31
  end
32
-
32
+
33
33
  it "should decode with marshal + base64" do
34
- RubyWarrior::Profile.decode(@profile.encode).warrior_name.should == @profile.warrior_name
34
+ expect(RubyWarrior::Profile.decode(@profile.encode).warrior_name).to eq(@profile.warrior_name)
35
35
  end
36
-
36
+
37
37
  it "load should read file, decode and set player path" do
38
38
  profile = 'profile'
39
39
  profile.expects(:player_path=).with('path/to')
40
40
  File.expects(:read).with('path/to/.profile').returns('encoded_profile')
41
41
  RubyWarrior::Profile.expects(:decode).with('encoded_profile').returns(profile)
42
- RubyWarrior::Profile.load('path/to/.profile').should == profile
42
+ expect(RubyWarrior::Profile.load('path/to/.profile')).to eq(profile)
43
43
  end
44
44
 
45
-
45
+
46
46
  it "should add abilities and remove duplicates" do
47
47
  @profile.add_abilities(:foo, :bar, :blah, :bar)
48
- @profile.abilities.should == [:foo, :bar, :blah]
48
+ expect(@profile.abilities).to eq([:foo, :bar, :blah])
49
49
  end
50
-
50
+
51
51
  it "should fetch new level with current number" do
52
52
  @profile.level_number = 1
53
- @profile.current_level.number.should == 1
53
+ expect(@profile.current_level.number).to eq(1)
54
54
  end
55
55
 
56
56
  it "should fetch next level" do
57
57
  @profile.level_number = 1
58
- @profile.next_level.number.should == 2
58
+ expect(@profile.next_level.number).to eq(2)
59
59
  end
60
60
 
61
61
  it "should enable epic mode and reset scores if nil" do
62
62
  @profile.epic_score = nil
63
63
  @profile.current_epic_score = nil
64
64
  @profile.enable_epic_mode
65
- @profile.should be_epic
66
- @profile.epic_score.should be_zero
67
- @profile.current_epic_score.should be_zero
65
+ expect(@profile).to be_epic
66
+ expect(@profile.epic_score).to be_zero
67
+ expect(@profile.current_epic_score).to be_zero
68
68
  end
69
-
69
+
70
70
  it "should override epic score with current one if it is higher" do
71
71
  @profile.enable_epic_mode
72
- @profile.epic_score.should be_zero
73
- @profile.average_grade.should be_nil
72
+ expect(@profile.epic_score).to be_zero
73
+ expect(@profile.average_grade).to be_nil
74
74
  @profile.current_epic_score = 123
75
75
  @profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
76
76
  @profile.update_epic_score
77
- @profile.epic_score.should == 123
78
- @profile.average_grade.should == 0.8
77
+ expect(@profile.epic_score).to eq(123)
78
+ expect(@profile.average_grade).to eq(0.8)
79
79
  end
80
-
80
+
81
81
  it "should not override epic score with current one if it is lower" do
82
82
  @profile.enable_epic_mode
83
83
  @profile.epic_score = 124
@@ -85,20 +85,20 @@ describe RubyWarrior::Profile do
85
85
  @profile.current_epic_score = 123
86
86
  @profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
87
87
  @profile.update_epic_score
88
- @profile.epic_score.should == 124
89
- @profile.average_grade.should == 0.9
88
+ expect(@profile.epic_score).to eq(124)
89
+ expect(@profile.average_grade).to eq(0.9)
90
90
  end
91
-
91
+
92
92
  it "should not calculate average grade if no grades are present" do
93
93
  @profile.enable_epic_mode
94
94
  @profile.current_epic_grades = {}
95
- @profile.calculate_average_grade.should be_nil
95
+ expect(@profile.calculate_average_grade).to be_nil
96
96
  end
97
97
 
98
98
  it "should remember current level number as last_level_number" do
99
99
  @profile.level_number = 7
100
100
  @profile.enable_epic_mode
101
- @profile.last_level_number.should == 7
101
+ expect(@profile.last_level_number).to eq(7)
102
102
  end
103
103
 
104
104
  it "should enable normal mode by clearing epic scores and resetting last level number" do
@@ -108,26 +108,26 @@ describe RubyWarrior::Profile do
108
108
  @profile.current_epic_grades = { 1 => 100 }
109
109
  @profile.average_grade = "C"
110
110
  @profile.enable_normal_mode
111
- @profile.should_not be_epic
112
- @profile.epic_score.should be_zero
113
- @profile.current_epic_score.should be_zero
114
- @profile.last_level_number.should be_nil
115
- @profile.average_grade.should be_nil
116
- @profile.current_epic_grades.should == {}
117
- @profile.level_number.should == 7
111
+ expect(@profile).to_not be_epic
112
+ expect(@profile.epic_score).to be_zero
113
+ expect(@profile.current_epic_score).to be_zero
114
+ expect(@profile.last_level_number).to be_nil
115
+ expect(@profile.average_grade).to be_nil
116
+ expect(@profile.current_epic_grades).to eq({})
117
+ expect(@profile.level_number).to eq(7)
118
118
  end
119
119
 
120
120
  it "should be no level after epic if last level isn't specified" do
121
121
  @profile.last_level_number = nil
122
- @profile.should_not be_level_after_epic
122
+ expect(@profile).to_not be_level_after_epic
123
123
  end
124
-
124
+
125
125
  describe "with tower path" do
126
126
  before(:each) do
127
127
  @profile.warrior_name = "John Smith"
128
128
  @profile.tower_path = 'path/to/tower'
129
129
  end
130
-
130
+
131
131
  it "save should write file with encoded profile" do
132
132
  file = stub
133
133
  file.expects(:write).with('encoded_profile')
@@ -135,37 +135,37 @@ describe RubyWarrior::Profile do
135
135
  @profile.expects(:encode).returns('encoded_profile')
136
136
  @profile.save
137
137
  end
138
-
138
+
139
139
  it "should have a nice string representation" do
140
140
  @profile.warrior_name = 'Joe'
141
- @profile.to_s.should == "Joe - tower - level 0 - score 0"
141
+ expect(@profile.to_s).to eq("Joe - tower - level 0 - score 0")
142
142
  end
143
-
143
+
144
144
  it "should include epic score in string representation" do
145
145
  @profile.warrior_name = 'Joe'
146
146
  @profile.enable_epic_mode
147
- @profile.to_s.should == "Joe - tower - first score 0 - epic score 0"
147
+ expect(@profile.to_s).to eq("Joe - tower - first score 0 - epic score 0")
148
148
  end
149
-
149
+
150
150
  it "should include epic score with grade in string representation" do
151
151
  @profile.warrior_name = 'Joe'
152
152
  @profile.enable_epic_mode
153
153
  @profile.average_grade = 0.7
154
- @profile.to_s.should == "Joe - tower - first score 0 - epic score 0 (C)"
154
+ expect(@profile.to_s).to eq("Joe - tower - first score 0 - epic score 0 (C)")
155
155
  end
156
-
156
+
157
157
  it "should guess at the player path" do
158
- @profile.player_path.should == './rubywarrior/john-smith-tower'
158
+ expect(@profile.player_path).to eq('./rubywarrior/john-smith-tower')
159
159
  end
160
-
160
+
161
161
  it "should use specified player path" do
162
162
  @profile.player_path = "path/to/player"
163
- @profile.player_path.should == "path/to/player"
163
+ expect(@profile.player_path).to eq("path/to/player")
164
164
  end
165
-
165
+
166
166
  it "should load tower from path" do
167
167
  RubyWarrior::Tower.expects(:new).with('tower').returns('tower')
168
- @profile.tower.should == 'tower'
168
+ expect(@profile.tower).to eq('tower')
169
169
  end
170
170
  end
171
171
  end
@@ -6,185 +6,185 @@ describe RubyWarrior::Space do
6
6
  @floor.width = 2
7
7
  @floor.height = 3
8
8
  end
9
-
9
+
10
10
  describe "with empty space" do
11
11
  before(:each) do
12
12
  @space = @floor.space(0, 0)
13
13
  end
14
-
14
+
15
15
  it "should not be enemy" do
16
- @space.should_not be_enemy
16
+ expect(@space).to_not be_enemy
17
17
  end
18
-
18
+
19
19
  it "should not be warrior" do
20
- @space.should_not be_warrior
20
+ expect(@space).to_not be_warrior
21
21
  end
22
-
22
+
23
23
  it "should be empty" do
24
- @space.should be_empty
24
+ expect(@space).to be_empty
25
25
  end
26
-
26
+
27
27
  it "should not be wall" do
28
- @space.should_not be_wall
28
+ expect(@space).to_not be_wall
29
29
  end
30
-
30
+
31
31
  it "should not be stairs" do
32
- @space.should_not be_stairs
32
+ expect(@space).to_not be_stairs
33
33
  end
34
-
34
+
35
35
  it "should not be captive" do
36
- @space.should_not be_captive
36
+ expect(@space).to_not be_captive
37
37
  end
38
-
38
+
39
39
  it "should say 'nothing' as name" do
40
- @space.to_s.should == 'nothing'
40
+ expect(@space.to_s).to eq('nothing')
41
41
  end
42
-
42
+
43
43
  it "should not be ticking" do
44
- @space.should_not be_ticking
44
+ expect(@space).to_not be_ticking
45
45
  end
46
46
  end
47
-
47
+
48
48
  describe "out of bounds" do
49
49
  before(:each) do
50
50
  @space = @floor.space(-1, 1)
51
51
  end
52
-
52
+
53
53
  it "should be wall" do
54
- @space.should be_wall
54
+ expect(@space).to be_wall
55
55
  end
56
-
56
+
57
57
  it "should not be empty" do
58
- @space.should_not be_empty
58
+ expect(@space).to_not be_empty
59
59
  end
60
-
60
+
61
61
  it "should have name of 'wall'" do
62
- @space.to_s.should == 'wall'
62
+ expect(@space.to_s).to eq('wall')
63
63
  end
64
64
  end
65
-
65
+
66
66
  describe "with warrior" do
67
67
  before(:each) do
68
68
  warrior = RubyWarrior::Units::Warrior.new
69
69
  @floor.add(warrior, 0, 0)
70
70
  @space = @floor.space(0, 0)
71
71
  end
72
-
72
+
73
73
  it "should be warrior" do
74
- @space.should be_warrior
74
+ expect(@space).to be_warrior
75
75
  end
76
-
76
+
77
77
  it "should be player" do
78
- @space.should be_warrior
78
+ expect(@space).to be_warrior
79
79
  end
80
-
80
+
81
81
  it "should not be enemy" do
82
- @space.should_not be_enemy
82
+ expect(@space).to_not be_enemy
83
83
  end
84
-
84
+
85
85
  it "should not be empty" do
86
- @space.should_not be_enemy
86
+ expect(@space).to_not be_enemy
87
87
  end
88
-
88
+
89
89
  it "should know what unit is on that space" do
90
- @space.unit.should be_kind_of(RubyWarrior::Units::Warrior)
90
+ expect(@space.unit).to be_kind_of(RubyWarrior::Units::Warrior)
91
91
  end
92
92
  end
93
-
93
+
94
94
  describe "with enemy" do
95
95
  before(:each) do
96
96
  @floor.add(RubyWarrior::Units::Sludge.new, 0, 0)
97
97
  @space = @floor.space(0, 0)
98
98
  end
99
-
99
+
100
100
  it "should be enemy" do
101
- @space.should be_enemy
101
+ expect(@space).to be_enemy
102
102
  end
103
-
103
+
104
104
  it "should not be warrior" do
105
- @space.should_not be_warrior
105
+ expect(@space).to_not be_warrior
106
106
  end
107
-
107
+
108
108
  it "should not be empty" do
109
- @space.should_not be_empty
109
+ expect(@space).to_not be_empty
110
110
  end
111
-
111
+
112
112
  it "should have name of unit" do
113
- @space.to_s.should == "Sludge"
113
+ expect(@space.to_s).to eq("Sludge")
114
114
  end
115
-
115
+
116
116
  describe "bound" do
117
117
  before(:each) do
118
118
  @space.unit.bind
119
119
  end
120
-
120
+
121
121
  it "should be captive" do
122
- @space.should be_captive
122
+ expect(@space).to be_captive
123
123
  end
124
-
124
+
125
125
  it "should not look like enemy" do
126
- @space.should_not be_enemy
126
+ expect(@space).to_not be_enemy
127
127
  end
128
128
  end
129
129
  end
130
-
130
+
131
131
  describe "with captive" do
132
132
  before(:each) do
133
133
  @captive = RubyWarrior::Units::Captive.new
134
134
  @floor.add(@captive, 0, 0)
135
135
  @space = @floor.space(0, 0)
136
136
  end
137
-
137
+
138
138
  it "should be captive" do
139
- @space.should be_captive
139
+ expect(@space).to be_captive
140
140
  end
141
-
141
+
142
142
  it "should not be enemy" do
143
- @space.should_not be_enemy
143
+ expect(@space).to_not be_enemy
144
144
  end
145
-
145
+
146
146
  it "should be ticking if captive has time bomb" do
147
147
  @captive.add_abilities :explode!
148
- @space.should be_ticking
148
+ expect(@space).to be_ticking
149
149
  end
150
-
150
+
151
151
  it "should not be ticking if captive does not have time bomb" do
152
- @space.should_not be_ticking
152
+ expect(@space).to_not be_ticking
153
153
  end
154
154
  end
155
-
155
+
156
156
  describe "with golem" do
157
157
  before(:each) do
158
158
  @golem = RubyWarrior::Units::Golem.new
159
159
  @floor.add(@golem, 0, 0)
160
160
  @space = @floor.space(0, 0)
161
161
  end
162
-
162
+
163
163
  it "should be golem" do
164
- @space.should be_golem
164
+ expect(@space).to be_golem
165
165
  end
166
-
166
+
167
167
  it "should not be enemy" do
168
- @space.should_not be_enemy
168
+ expect(@space).to_not be_enemy
169
169
  end
170
-
170
+
171
171
  it "should be player" do
172
- @space.should be_player
172
+ expect(@space).to be_player
173
173
  end
174
174
  end
175
-
175
+
176
176
  describe "at stairs" do
177
177
  before(:each) do
178
178
  @floor.place_stairs(0, 0)
179
179
  @space = @floor.space(0, 0)
180
180
  end
181
-
181
+
182
182
  it "should be empty" do
183
- @space.should be_empty
183
+ expect(@space).to be_empty
184
184
  end
185
-
185
+
186
186
  it "should be stairs" do
187
- @space.should be_stairs
187
+ expect(@space).to be_stairs
188
188
  end
189
189
  end
190
190
  end
@@ -4,12 +4,12 @@ describe RubyWarrior::Tower do
4
4
  before(:each) do
5
5
  @tower = RubyWarrior::Tower.new('path/to/tower')
6
6
  end
7
-
7
+
8
8
  it "should consider last part of path as name" do
9
- @tower.name.should == 'tower'
9
+ expect(@tower.name).to eq('tower')
10
10
  end
11
-
11
+
12
12
  it "should use name when converting to string" do
13
- @tower.to_s.should == @tower.name
13
+ expect(@tower.to_s).to eq(@tower.name)
14
14
  end
15
15
  end
@@ -5,27 +5,27 @@ describe RubyWarrior::Turn do
5
5
  before(:each) do
6
6
  @turn = RubyWarrior::Turn.new({:walk! => nil, :attack! => nil})
7
7
  end
8
-
8
+
9
9
  it "should have no action performed at first" do
10
- @turn.action.should be_nil
10
+ expect(@turn.action).to be_nil
11
11
  end
12
-
12
+
13
13
  it "should be able to perform action and recall it" do
14
14
  @turn.walk!
15
- @turn.action.should == [:walk!]
15
+ expect(@turn.action).to eq([:walk!])
16
16
  end
17
-
17
+
18
18
  it "should include arguments passed to action" do
19
19
  @turn.walk! :forward
20
- @turn.action.should == [:walk!, :forward]
20
+ expect(@turn.action).to eq([:walk!, :forward])
21
21
  end
22
-
22
+
23
23
  it "should not be able to call multiple actions per turn" do
24
24
  @turn.walk! :forward
25
- lambda { @turn.attack! }.should raise_error
25
+ expect { @turn.attack! }.to raise_error("Only one action can be performed per turn.")
26
26
  end
27
27
  end
28
-
28
+
29
29
  describe "with senses" do
30
30
  before(:each) do
31
31
  @feel = RubyWarrior::Abilities::Feel.new(Object.new)
@@ -33,10 +33,10 @@ describe RubyWarrior::Turn do
33
33
  @feel.stubs(:space).with(:backward).returns(Object.new)
34
34
  @turn = RubyWarrior::Turn.new({:feel => @feel})
35
35
  end
36
-
36
+
37
37
  it "should be able to call sense with any argument and return expected results" do
38
- @turn.feel.should == @feel.perform
39
- @turn.feel(:backward).should == @feel.perform(:backward)
38
+ expect(@turn.feel).to eq(@feel.perform)
39
+ expect(@turn.feel(:backward)).to eq(@feel.perform(:backward))
40
40
  end
41
41
  end
42
42
  end
@@ -9,82 +9,82 @@ describe RubyWarrior::UI do
9
9
  @config.out_stream = @out
10
10
  @config.in_stream = @in
11
11
  end
12
-
12
+
13
13
  it "should add puts to out stream" do
14
14
  @ui.puts "hello"
15
- @out.string.should == "hello\n"
15
+ expect(@out.string).to eq("hello\n")
16
16
  end
17
-
17
+
18
18
  it "should add print to out stream without newline" do
19
19
  @ui.print "hello"
20
- @out.string.should == "hello"
20
+ expect(@out.string).to eq("hello")
21
21
  end
22
-
22
+
23
23
  it "should fetch gets from in stream" do
24
24
  @in.puts "bar"
25
25
  @in.rewind
26
- @ui.gets.should == "bar\n"
26
+ expect(@ui.gets).to eq("bar\n")
27
27
  end
28
-
28
+
29
29
  it "should gets should return empty string if no input" do
30
30
  @config.in_stream = nil
31
- @ui.gets.should == ""
31
+ expect(@ui.gets).to eq("")
32
32
  end
33
-
33
+
34
34
  it "should request text input" do
35
35
  @in.puts "bar"
36
36
  @in.rewind
37
- @ui.request("foo").should == "bar"
38
- @out.string.should == "foo"
37
+ expect(@ui.request("foo")).to eq("bar")
38
+ expect(@out.string).to eq("foo")
39
39
  end
40
-
40
+
41
41
  it "should ask for yes/no and return true when yes" do
42
42
  @ui.expects(:request).with('foo? [yn] ').returns('y')
43
- @ui.ask("foo?").should be_true
43
+ expect(@ui.ask("foo?")).to eq(true)
44
44
  end
45
-
45
+
46
46
  it "should ask for yes/no and return false when no" do
47
47
  @ui.stubs(:request).returns('n')
48
- @ui.ask("foo?").should be_false
48
+ expect(@ui.ask("foo?")).to eq(false)
49
49
  end
50
-
50
+
51
51
  it "should ask for yes/no and return false for any input" do
52
52
  @ui.stubs(:request).returns('aklhasdf')
53
- @ui.ask("foo?").should be_false
53
+ expect(@ui.ask("foo?")).to eq(false)
54
54
  end
55
-
55
+
56
56
  it "should present multiple options and return selected one" do
57
57
  @ui.expects(:request).with(includes('item')).returns('2')
58
- @ui.choose('item', [:foo, :bar, :test]).should == :bar
59
- @out.string.should include('[1] foo')
60
- @out.string.should include('[2] bar')
61
- @out.string.should include('[3] test')
58
+ expect(@ui.choose('item', [:foo, :bar, :test])).to eq(:bar)
59
+ expect(@out.string).to include('[1] foo')
60
+ expect(@out.string).to include('[2] bar')
61
+ expect(@out.string).to include('[3] test')
62
62
  end
63
-
63
+
64
64
  it "choose should accept array as option" do
65
65
  @ui.stubs(:request).returns('3')
66
- @ui.choose('item', [:foo, :bar, [:tower, 'easy']]).should == :tower
67
- @out.string.should include('[3] easy')
66
+ expect(@ui.choose('item', [:foo, :bar, [:tower, 'easy']])).to eq(:tower)
67
+ expect(@out.string).to include('[3] easy')
68
68
  end
69
-
69
+
70
70
  it "choose should return option without prompt if only one item" do
71
71
  @ui.expects(:puts).never
72
72
  @ui.expects(:gets).never
73
73
  @ui.stubs(:request).returns('3')
74
- @ui.choose('item', [:foo]).should == :foo
74
+ expect(@ui.choose('item', [:foo])).to eq(:foo)
75
75
  end
76
-
76
+
77
77
  it "choose should return first value in array of option if only on item" do
78
- @ui.choose('item', [[:foo, :bar]]).should == :foo
78
+ expect(@ui.choose('item', [[:foo, :bar]])).to eq(:foo)
79
79
  end
80
-
80
+
81
81
  it "should delay after puts when specified" do
82
82
  @config.delay = 1.3
83
83
  @ui.expects(:puts).with("foo")
84
84
  @ui.expects(:sleep).with(1.3)
85
85
  @ui.puts_with_delay("foo")
86
86
  end
87
-
87
+
88
88
  it "should not delay puts when delay isn't specified" do
89
89
  @ui.expects(:puts).with("foo")
90
90
  @ui.expects(:sleep).never