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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions spec/scene_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.