Permalink
Browse files

Better "auto-update code" spec.

  • Loading branch information...
1 parent 6791fe2 commit 6120486bc78007a915b8dea98f17d6f341e22cb8 @mauricioszabo committed Dec 3, 2011
Showing with 8 additions and 7 deletions.
  1. +0 −2 lib/scene.rb
  2. +8 −5 spec/scene_spec.rb
View
@@ -36,8 +36,6 @@ def register_to(code, player)
end
def update_codes
- #[@code1, @code2].compact.each do |code|
- #end
update_player_info @code1, @p1, @p2, @p1_energy, @p2_energy if @code1
update_player_info @code2, @p2, @p1, @p2_energy, @p1_energy if @code2
end
View
@@ -23,11 +23,14 @@ class Energy; attr_reader :tank, :energy; end
end
it 'should update the code' do
- code = mock("Code")
- code.stub!(:register_to).and_return(code_instance = mock("Code Instance").as_null_object)
- code_instance.should_receive(:run).twice
- scene.register_to code, :p1
- scene.register_to code, :p2
+ code1 = mock("Code")
+ code1.stub!(:register_to).and_return(code_instance1 = mock("Code Instance").as_null_object)
+ code2 = mock("Code")
+ code2.stub!(:register_to).and_return(code_instance2 = mock("Code Instance").as_null_object)
+ code_instance1.should_receive(:run)
+ code_instance2.should_receive(:run)
+ scene.register_to code1, :p1
+ scene.register_to code2, :p2
scene.update
end
end

0 comments on commit 6120486

Please sign in to comment.