Skip to content

Commit 5e716ec

Browse files
committed
fixing specs for relative tower path behavior
1 parent c80d4e2 commit 5e716ec

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

lib/ruby_warrior/game.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def towers
156156
end
157157

158158
def tower_paths
159-
Dir[File.expand_path(File.dirname(__FILE__) + '/../../towers/*')]
159+
Dir[File.expand_path('../../../towers/*', __FILE__)]
160160
end
161161

162162

lib/ruby_warrior/level.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def player_path
2525

2626
def load_path
2727
File.join(
28-
File.expand_path(File.dirname(__FILE__) + '/../../towers/'),
28+
File.expand_path('../../../towers/', __FILE__),
2929
File.basename(@profile.tower_path) + "/level_" +
3030
@number.to_s.rjust(3, '0') + ".rb"
3131
)

lib/ruby_warrior/player_generator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def generate
2929
end
3030

3131
def templates_path
32-
File.expand_path(File.dirname(__FILE__) + "/../../templates")
32+
File.expand_path("../../../templates", __FILE__)
3333
end
3434

3535
private

lib/ruby_warrior/tower.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Tower
33
attr_reader :path
44

55
def initialize(path)
6-
@path = File.join(File.expand_path(File.dirname(__FILE__) + '/../../towers/'), path)
6+
@path = File.join(File.expand_path('../../../towers/', __FILE__), path)
77
end
88

99
def name

spec/ruby_warrior/game_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
end
7575

7676
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__))
7878
@game.tower_paths
7979
end
8080

spec/ruby_warrior/level_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
it "should have a load path from profile tower with level number in it" do
5353
@profile.stubs(:tower_path).returns('path/to/tower')
54-
@level.load_path.should == 'path/to/tower/level_001.rb'
54+
@level.load_path.should == File.expand_path('towers/tower/level_001.rb')
5555
end
5656

5757
it "should exist if file exists" do

spec/ruby_warrior/player_generator_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
end
88

99
it "should know templates path" do
10-
@generator.templates_path.should == File.expand_path(File.dirname(__FILE__) + "/../../templates")
10+
@generator.templates_path.should == File.expand_path("../../../templates", __FILE__)
1111
end
1212
end

spec/ruby_warrior/profile_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
end
165165

166166
it "should load tower from path" do
167-
RubyWarrior::Tower.expects(:new).with('path/to/tower').returns('tower')
167+
RubyWarrior::Tower.expects(:new).with('tower').returns('tower')
168168
@profile.tower.should == 'tower'
169169
end
170170
end

0 commit comments

Comments
 (0)