Module: GameboxAcceptanceSpecHelpers::InstanceMethods
- Defined in:
- lib/gamebox/spec/helper.rb
Instance Method Summary (collapse)
- - (Object) draw
- - (Object) game
- - (Object) gosu
- - (Object) mock_font(name, size)
- - (Object) mock_image(filename, w = 10, h = 20)
- - (Object) mock_tiles(filename, width, height)
- - (Object) pause
- - (Object) press_key(button_id)
- - (Object) release_key(button_id)
- - (Object) remove_actor(actor_type)
- - (Object) see_actor_attrs(actor_type, attrs)
- - (Object) see_actor_drawn(actor_type)
- - (Object) see_image_drawn(img)
- - (Object) see_image_not_drawn(img)
- - (Object) see_no_actor_attrs(actor_type, *attrs)
- - (Object) see_stage_ivars(ivar_hash)
- - (Object) see_text_drawn(text, opts)
- - (Object) unpause
- - (Object) update(time, opts = {})
Instance Method Details
- (Object) draw
443 444 445 |
# File 'lib/gamebox/spec/helper.rb', line 443 def draw gosu.draw end |
- (Object) game
455 456 457 458 459 460 461 462 |
# File 'lib/gamebox/spec/helper.rb', line 455 def game context = Conject.default_object_context @game ||= context[:testing_game].tap do |g| g.configure input_manager = context[:input_manager] input_manager.register g end end |
- (Object) gosu
464 465 466 |
# File 'lib/gamebox/spec/helper.rb', line 464 def gosu @gosu ||= MockGosuWindow.new end |
- (Object) mock_font(name, size)
392 393 394 395 396 397 398 |
# File 'lib/gamebox/spec/helper.rb', line 392 def mock_font(name, size) context = Conject.default_object_context resource_manager = context[:resource_manager] MockFont.new(name, size).tap do |font| resource_manager.stubs(:load_font).with(name, size).returns(font) end end |
- (Object) mock_image(filename, w = 10, h = 20)
352 353 354 355 356 357 358 |
# File 'lib/gamebox/spec/helper.rb', line 352 def mock_image(filename, w=10, h=20) context = Conject.default_object_context resource_manager = context[:resource_manager] MockImage.new(filename, w, h).tap do |img| resource_manager.stubs(:load_image).with(filename).returns(img) end end |
- (Object) mock_tiles(filename, width, height)
339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/gamebox/spec/helper.rb', line 339 def mock_tiles(filename, width, height) context = Conject.default_object_context resource_manager = context[:resource_manager] [].tap do |tiles| (width * height).times do |i| tiles << MockImage.new("#{filename}_#{i}", 16, 16) end resource_manager.stubs(:load_tiles).returns(tiles) end end |
- (Object) pause
406 407 408 |
# File 'lib/gamebox/spec/helper.rb', line 406 def pause game.current_stage.pause end |
- (Object) press_key(button_id)
451 452 453 |
# File 'lib/gamebox/spec/helper.rb', line 451 def press_key() gosu. end |
- (Object) release_key(button_id)
447 448 449 |
# File 'lib/gamebox/spec/helper.rb', line 447 def release_key() gosu. end |
- (Object) remove_actor(actor_type)
414 415 416 417 418 |
# File 'lib/gamebox/spec/helper.rb', line 414 def remove_actor(actor_type) act = game.actor(actor_type) act.should be act.remove end |
- (Object) see_actor_attrs(actor_type, attrs)
420 421 422 423 424 |
# File 'lib/gamebox/spec/helper.rb', line 420 def see_actor_attrs(actor_type, attrs) act = game.actor(actor_type) act.should be act.should have_attrs(attrs) end |
- (Object) see_actor_drawn(actor_type)
360 361 362 363 |
# File 'lib/gamebox/spec/helper.rb', line 360 def see_actor_drawn(actor_type) act = game.actor(actor_type) act.should be end |
- (Object) see_image_drawn(img)
365 366 367 368 369 |
# File 'lib/gamebox/spec/helper.rb', line 365 def see_image_drawn(img) img.calls.should_not be_empty img.calls.first.first.should == :draw img._reset! end |
- (Object) see_image_not_drawn(img)
371 372 373 |
# File 'lib/gamebox/spec/helper.rb', line 371 def see_image_not_drawn(img) img.calls.should be_empty end |
- (Object) see_no_actor_attrs(actor_type, *attrs)
426 427 428 429 430 |
# File 'lib/gamebox/spec/helper.rb', line 426 def see_no_actor_attrs(actor_type, *attrs) act = game.actor(actor_type) act.should be act.should have_no_attrs(attrs) end |
- (Object) see_stage_ivars(ivar_hash)
400 401 402 403 404 |
# File 'lib/gamebox/spec/helper.rb', line 400 def see_stage_ivars(ivar_hash) ivar_hash.each do |name, val| game.current_stage.instance_variable_get("@#{name}").should == val end end |
- (Object) see_text_drawn(text, opts)
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/gamebox/spec/helper.rb', line 375 def see_text_drawn(text, opts) font = opts[:in] font.calls.should_not be_empty first_call = font.calls.first first_call[0].should == :draw first_call[1].to_s.should == text first_call[2].should == opts[:x] if opts[:x] first_call[3].should == opts[:y] if opts[:y] first_call[4].should == opts[:z] if opts[:z] first_call[5].should == opts[:x_scale] if opts[:x_scale] first_call[6].should == opts[:y_scale] if opts[:y_scale] first_call[7].should == opts[:color] if opts[:color] font._reset! end |
- (Object) unpause
410 411 412 |
# File 'lib/gamebox/spec/helper.rb', line 410 def unpause game.current_stage.unpause end |
- (Object) update(time, opts = {})
432 433 434 435 436 437 438 439 440 441 |
# File 'lib/gamebox/spec/helper.rb', line 432 def update(time, opts={}) step = opts[:step] || time num_updates = time / step num_updates.times do gosu.update step end left_over = time % step gosu.update left_over unless left_over == 0 end |