Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tested world state

  • Loading branch information...
commit 97a92da315c28949955a591ca4487a77e62909ac 1 parent 1d4d3b1
@bgoodspeed authored
View
3  lib/domain/world_state.rb
@@ -1,6 +1,6 @@
class WorldState
- attr_reader :topo_interpreter, :interaction_interpreter,:npcs, :background_surface, :background_music
+ attr_accessor :topo_interpreter, :interaction_interpreter,:npcs, :background_surface, :background_music
extend Forwardable
def_delegator :@topo_interpreter, :update, :update_topo_map
@@ -56,7 +56,6 @@ def blit_world(screen, player)
}
end
-
def replace_bgsurface(orig_world)
@background_surface = orig_world.background_surface
end
View
43 spec/domain/world_state_spec.rb
@@ -3,12 +3,51 @@
describe WorldState do
include MethodDefinitionMatchers
-
+ include DomainMocks
before(:each) do
- @world_state = WorldState.new(@topointerp, @interinterp, [], nil, @bgm)
+ @topo = mock_interpreter
+ @inter = mock_interpreter
+ @world_state = WorldState.new(@topo,@inter, [:monster1, :monster2], nil, @bgm)
+ @world_state2 = WorldState.new(mock_interpreter, mock_interpreter, [], nil, @bgm)
end
it "should define methods" do
@world_state.should define(:background_music)
end
+
+ it "should replace pallettes" do
+ expect_replace_pallette(@inter)
+ @world_state.replace_pallettes(@world_state2)
+ end
+ it "should replace bgsurfaces" do
+ @world_state2.background_surface = :bar
+ @world_state.replace_bgsurface(@world_state2)
+ @world_state.background_surface.should == :bar
+ end
+ it "should replace bgmusic" do
+ @world_state2.background_music = :bar
+ @world_state.replace_bgmusic(@world_state2)
+ @world_state.background_music.should == :bar
+ end
+
+ it "should be able to draw by blits and draw calls" do
+ @world_state.background_surface = mock_surface
+ mon = mock_monster
+ @world_state.npcs = [mon]
+ expect_blitted(@world_state.background_surface)
+ expect_blit_foreground(@world_state.interaction_interpreter)
+ expect_nearby_and_drawn(mon)
+ @world_state.blit_world(mock_screen, mock_player)
+ end
+ it "should track npcs" do
+ @world_state.add_npc(:monster3)
+ @world_state.npcs.should == [:monster1, :monster2, :monster3]
+ @world_state.delete_monster(:monster3)
+ @world_state.npcs.should == [:monster1, :monster2]
+ end
+
+ it "should be json ified" do
+ @world_state.json_params.should be_an_instance_of(Array)
+ end
+
end
View
11 spec/rspec_helper.rb
@@ -84,7 +84,9 @@ def expect_set_frame_from(m, key)
def expect_world_change(uni)
uni.should_receive(:set_current_world_by_index)
end
-
+ def expect_replace_pallette(m)
+ m.should_receive(:replace_pallette)
+ end
def expect_fades_out_bg_music(uni)
uni.should_receive(:fade_out_bg_music)
end
@@ -176,7 +178,14 @@ def expect_draw_weapon(m)
def expect_event_handled(m)
m.should_receive(:handle)
end
+ def expect_blit_foreground(m)
+ m.should_receive(:blit_foreground)
+ end
+ def expect_nearby_and_drawn(m)
+ m.should_receive(:nearby?).and_return true
+ m.should_receive(:draw)
+ end
def expect_enter_current_cursor_location(m)
m.should_receive(:enter_current_cursor_location)
end
Please sign in to comment.
Something went wrong with that request. Please try again.