Sha256: 5fc2b55a8c2aec59dc2e13166ccea17a2e44c2fb9276116ee6c45e36d977b6b0

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

describe "UIControlWrap" do
  describe 'UIButton' do
    before do
      @button = UIButton.buttonWithType(UIButtonTypeRoundedRect) 
      @touched = []
      @button.when(UIControlEventTouchUpInside) do
        @touched << 'for the very first time'
      end
    end

    it "supports the 'when' event handler for UIButton" do
      @button.sendActionsForControlEvents(UIControlEventTouchUpInside)
      @touched.should == ['for the very first time']
    end

    it "replaces the target for a given control event by default" do
      @button.when(UIControlEventTouchUpInside) do
        @touched << 'touched'
      end
      @button.sendActionsForControlEvents(UIControlEventTouchUpInside)
      @touched.should == ['touched']
    end

    it "allows multiple targets for a given control event if specified" do
      @button.when(UIControlEventTouchUpInside, append: true) do
        @touched << 'touched'
      end
      @button.sendActionsForControlEvents(UIControlEventTouchUpInside)
      @touched.should == ['for the very first time', 'touched']
    end
  end

  it "supports the 'when' event handler for UISlider" do
    button = UISlider.alloc.init
    changed = nil
    button.when(UIControlEventValueChanged) do
      changed = 1
    end
    button.sendActionsForControlEvents(UIControlEventValueChanged)
    changed.should == 1
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bubble-wrap-1.3.0 spec/motion/ui/ui_control_spec.rb
bubble-wrap-1.3.0.osx spec/motion/ui/ui_control_spec.rb
bubble-wrap-1.2.0 spec/motion/core/ui_control_spec.rb
bubble-wrap-1.2.0.pre spec/motion/core/ui_control_spec.rb
bubble-wrap-1.1.5 spec/motion/core/ui_control_spec.rb
bubble-wrap-1.1.4 spec/motion/core/ui_control_spec.rb