Module: GameboxAcceptanceSpecHelpers
- Defined in:
- lib/gamebox/spec/helper.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, MockCalls
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/gamebox/spec/helper.rb', line 470 def self.included(base) base.send :include, InstanceMethods base.send :extend, ClassMethods RSpec::Matchers.define :have_actor do |actor_type| match do |game| !game.stage_manager.current_stage.actors.detect { |act| act.actor_type == actor_type }.nil? end end RSpec::Matchers.define :have_attrs do |expected_attributes| match do |actor| relevant_attrs = actual.attributes.slice(*expected[0].keys) relevant_attrs.should == expected_attributes end do |actual| relevant_attrs = actual.attributes.slice(*expected[0].keys) "#{relevant_attrs} did not match #{expected[0]}" end do |actual| relevant_attrs = actual.attributes.slice(*expected[0].keys) "#{relevant_attrs} matched #{expected[0]}" end end RSpec::Matchers.define :have_no_attrs do |expected_attributes| match do |actor| expected_attributes.each do |name| actor.has_attribute?(name).should be_false end end do |actual| relevant_attrs = actual.attributes.slice(*expected[0].keys) "#{relevant_attrs} matched #{expected[0]}" end do |actual| relevant_attrs = actual.attributes.slice(*expected[0].keys) "#{relevant_attrs} matched but should not have #{expected[0]}" end end end |