Skip to content

Commit

Permalink
Better "auto-update code" spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioszabo committed Dec 3, 2011
1 parent 6791fe2 commit 6120486
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions lib/scene.rb
Expand Up @@ -36,8 +36,6 @@ def register_to(code, player)
end end


def update_codes 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 @code1, @p1, @p2, @p1_energy, @p2_energy if @code1
update_player_info @code2, @p2, @p1, @p2_energy, @p1_energy if @code2 update_player_info @code2, @p2, @p1, @p2_energy, @p1_energy if @code2
end end
Expand Down
13 changes: 8 additions & 5 deletions spec/scene_spec.rb
Expand Up @@ -23,11 +23,14 @@ class Energy; attr_reader :tank, :energy; end
end end


it 'should update the code' do it 'should update the code' do
code = mock("Code") code1 = mock("Code")
code.stub!(:register_to).and_return(code_instance = mock("Code Instance").as_null_object) code1.stub!(:register_to).and_return(code_instance1 = mock("Code Instance").as_null_object)
code_instance.should_receive(:run).twice code2 = mock("Code")
scene.register_to code, :p1 code2.stub!(:register_to).and_return(code_instance2 = mock("Code Instance").as_null_object)
scene.register_to code, :p2 code_instance1.should_receive(:run)
code_instance2.should_receive(:run)
scene.register_to code1, :p1
scene.register_to code2, :p2
scene.update scene.update
end end
end end

0 comments on commit 6120486

Please sign in to comment.