Sha256: 008b2f67e02e3058fe02643d9f52c894c7fc3d972f95452bf64bd1e4ad840aa2

Contents?: true

Size: 1.64 KB

Versions: 27

Compression:

Stored size: 1.64 KB

Contents

require File.join(File.dirname(__FILE__), '/../../spec_helper')

describe Controls do
  
  describe 'handle' do
    before(:each) do
      @handler1 = stub :handler1
      @handler2 = stub :handler2
      @handler3 = stub :handler3
      
      @controls = Controls.new @handler2, @handler1, @handler3
    end
    it 'should call each handle method' do
      @handler1.should_receive(:handle).once.with
      @handler2.should_receive(:handle).once.with
      @handler3.should_receive(:handle).once.with
      
      @controls.handle
    end
  end
  
  describe 'remove_all_of' do
    before(:each) do
      @controllable = stub :controllable
      @remove    = stub :remove, :controllable => @controllable
      @nonremove = stub :nonremove, :controllable => :some_other_controllable
      
      @controls = Controls.new @remove, @nonremove, @remove, @nonremove, @nonremove, @nonremove
    end
    it 'should remove the right control' do
      @controls.remove_all_of @controllable
      
      @controls.controls.size.should == 4
    end
  end
  
  describe '<<' do
    before(:each) do
      @controls = Controls.new
      @control = stub :control
    end
    it 'should not add nil' do
      @control = nil
      
      @controls << @control
      
      @controls.controls.empty?.should == true
    end
    it 'should not add mapping? false' do
      @control.stub! :mapping? => false
      
      @controls << @control
      
      @controls.controls.empty?.should == true
    end
    it 'should add non-nil, mapping? true' do
      @control.stub! :mapping? => true
      
      @controls << @control
      
      @controls.controls.size.should == 1
    end
  end
  
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
gosu_extensions-0.3.8 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.7 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.6 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.5 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.4 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.3 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.2 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.1 spec/lib/core/controls_spec.rb
gosu_extensions-0.3.0 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.9 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.8 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.7 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.6 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.5 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.4 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.3 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.2 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.1 spec/lib/core/controls_spec.rb
gosu_extensions-0.2.0 spec/lib/core/controls_spec.rb
gosu_extensions-0.1.28 spec/lib/core/controls_spec.rb