Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added more coverage on Scene.

  • Loading branch information...
commit 4e8c1b932d0729ba820ba82a3d785ac70b87d844 1 parent 0928801
@mauricioszabo authored
Showing with 26 additions and 5 deletions.
  1. +1 −5 lib/scene.rb
  2. +25 −0 spec/scene_spec.rb
View
6 lib/scene.rb
@@ -27,10 +27,6 @@ def draw
@p1_energy.draw_on @screen, 20, 0
@p2_energy.draw_on @screen, WIDTH-130, 0
@p1.draw_on @screen
- end
-
- private
- def dir_for(file)
- File.join(DIR, file)
+ @p2.draw_on @screen
end
end
View
25 spec/scene_spec.rb
@@ -0,0 +1,25 @@
+require_relative "helper"
+
+describe Scene do
+ let(:scene) { Scene.new(screen) }
+ let(:screen) { MockScreen.new }
+
+ class Scene; attr_reader :p1, :p2; end
+ class Energy; attr_reader :tank, :energy; end
+
+ it 'should draw the initial energy tanks' do
+ energy = Energy.new
+ Energy.stub!(:new).and_return(energy)
+ scene.draw
+ screen.should have(2).objects_like(energy.tank)
+ end
+
+ it 'should draw the ships on screen' do
+ p1 = scene.p1
+ p2 = scene.p2
+ scene.draw
+ screen.should have_a(p1.surface)
+ screen.should have_a(p2.surface)
+
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.