spec/ios/uiactionsheet_spec.rb in sugarcube-2.4.1 vs spec/ios/uiactionsheet_spec.rb in sugarcube-2.4.2

- old
+ new

@@ -5,24 +5,24 @@ @touched = nil end it 'should have :show option (show: false)' do alert = UIActionSheet.alert('test', show: false) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == false end it 'should have :show option (show: true)' do alert = UIActionSheet.alert('test', show: true) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should show by default' do alert = UIActionSheet.alert('test') - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should assign the title' do @@ -54,21 +54,21 @@ end end it 'should have :from option that accepts CGRect' do alert = UIActionSheet.alert('test', from: CGRect.new([0, 0], [320, 0])) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should have :from option that accepts CGRect and a :view that accepts UIView' do view = UIView.alloc.initWithFrame(UIScreen.mainScreen.bounds) window = UIApplication.sharedApplication.windows[0] window << view alert = UIActionSheet.alert('test', from: CGRect.new([0, 0], [320, 0]), view: view) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should have :from option that accepts UIBarButtonItem' do @@ -76,41 +76,41 @@ toolbar = UIToolbar.alloc.initWithFrame(UIScreen.mainScreen.bounds) toolbar.items = [button] window = UIApplication.sharedApplication.windows[0] window << toolbar alert = UIActionSheet.alert('test', from: button) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should have :from option that accepts UIToolbar' do view = UIToolbar.alloc.initWithFrame(UIScreen.mainScreen.bounds) window = UIApplication.sharedApplication.windows[0] window << view alert = UIActionSheet.alert('test', from: view) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should have :from option that accepts UITabBar' do view = UITabBar.alloc.initWithFrame(UIScreen.mainScreen.bounds) window = UIApplication.sharedApplication.windows[0] window << view alert = UIActionSheet.alert('test', from: view) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should have :from option that accepts UIView' do view = UIView.alloc.initWithFrame(UIScreen.mainScreen.bounds) window = UIApplication.sharedApplication.windows[0] window << view alert = UIActionSheet.alert('test', from: view) - proper_wait 0.6 + proper_wait 0.5 alert.visible?.should == true alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) end it 'should add a button with << method' do @@ -127,46 +127,51 @@ alert.buttonTitleAtIndex(alert.firstOtherButtonIndex).should == 'OK' end it 'should call block when pressed' do alert = UIActionSheet.alert('test') { @touched = true } - proper_wait 0.6 + proper_wait 0.5 alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == true end it 'should call block with "OK" pressed' do alert = UIActionSheet.alert('test') { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 alert.dismissWithClickedButtonIndex(alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'OK' end describe 'with all :buttons defined' do before do @touched = nil @touched_index = nil @alert = UIActionSheet.alert('test', buttons: ['cancel', 'destructive', 'ok']) { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 end it 'should call block with "cancel" when cancel button is pressed' do @alert.cancelButtonIndex.should == 2 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'cancel' end it 'should call block with "destructive" when destructive button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'destructive' end it 'should call block with "ok" when other button is pressed' do @alert.firstOtherButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'ok' end end @@ -174,27 +179,29 @@ before do @touched = nil @touched_index = nil @alert = UIActionSheet.alert('test', buttons: ['cancel', 'destructive']) { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 end after do @alert.dismissWithClickedButtonIndex(-1, animated: false) if @alert.visible? end it 'should call block with "cancel" when cancel button is pressed' do @alert.cancelButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'cancel' @touched_index.should == @alert.cancelButtonIndex end it 'should call block with "destructive" when destructive button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'destructive' @touched_index.should == @alert.destructiveButtonIndex end it 'should not have other buttons' do @@ -207,20 +214,21 @@ before do @touched = nil @touched_index = nil @alert = UIActionSheet.alert('test', buttons: ['cancel', nil, 'ok']) { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 end after do @alert.dismissWithClickedButtonIndex(-1, animated: false) if @alert.visible? end it 'should call block with "cancel" when cancel button is pressed' do @alert.cancelButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'cancel' @touched_index.should == @alert.cancelButtonIndex end it 'should not have destructive button' do @@ -228,10 +236,11 @@ end it 'should call block with "ok" when other button is pressed' do @alert.firstOtherButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'ok' @touched_index.should == @alert.firstOtherButtonIndex end end @@ -240,11 +249,11 @@ before do @touched = nil @touched_index = nil @alert = UIActionSheet.alert('test', buttons: [nil, 'destructive', 'ok']) { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 end after do @alert.dismissWithClickedButtonIndex(-1, animated: false) if @alert.visible? end @@ -254,17 +263,19 @@ end it 'should call block with "destructive" when destructive button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'destructive' @touched_index.should == @alert.destructiveButtonIndex end it 'should call block with "ok" when other button is pressed' do @alert.firstOtherButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'ok' @touched_index.should == @alert.firstOtherButtonIndex end end @@ -273,11 +284,11 @@ before do @touched = nil @touched_index = nil @alert = UIActionSheet.alert('test', buttons: [nil, nil, 'test1', 'test2']) { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 end after do @alert.dismissWithClickedButtonIndex(-1, animated: false) if @alert.visible? end @@ -291,16 +302,18 @@ end it 'should call block with "test1" when first button is pressed' do @alert.firstOtherButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'test1' @touched_index.should == @alert.firstOtherButtonIndex end it 'should call block with "test2" when second button is pressed' do @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex + 1, animated: false) + proper_wait 0.5 @touched.should == 'test2' @touched_index.should == @alert.firstOtherButtonIndex + 1 end end @@ -315,40 +328,40 @@ cancel: 'Cancel', destructive: 'Destructive', test1: 'Test1', test2: 'Test2', }) { |button, index| @touched, @touched_index = button, index } - proper_wait 0.6 + proper_wait 0.5 end - after do - # @alert.dismissWithClickedButtonIndex(-1, animated: false) if @alert.visible? - end - it 'should call block with :destructive when cancel button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :destructive @touched_index.should == @alert.destructiveButtonIndex end it 'should call block with :cancel when cancel button is pressed' do @alert.cancelButtonIndex.should == 3 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :cancel @touched_index.should == @alert.cancelButtonIndex end it 'should call block with :test1 when first button is pressed' do @alert.firstOtherButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :test1 @touched_index.should == @alert.firstOtherButtonIndex end it 'should call block with :test2 when second button is pressed' do @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex + 1, animated: false) + proper_wait 0.5 @touched.should == :test2 @touched_index.should == @alert.firstOtherButtonIndex + 1 end end @@ -362,34 +375,38 @@ buttons: ['cancel', 'destructive', 'test1', 'test2'], cancel: ->{ @touched = :cancel }, destructive: ->{ @touched = :destructive }, success: ->(button, index){ @touched, @touched_index = button, index }, ) - proper_wait 0.6 + proper_wait 0.5 end it 'should call block with :cancel when cancel button is pressed' do @alert.cancelButtonIndex.should == 3 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :cancel end it 'should call block with :destructive when destructive button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :destructive end it 'should call block with "test1" when first button is pressed' do @alert.firstOtherButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'test1' @touched_index.should == @alert.firstOtherButtonIndex end it 'should call block with "test2" when second button is pressed' do @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex + 1, animated: false) + proper_wait 0.5 @touched.should == 'test2' @touched_index.should == @alert.firstOtherButtonIndex + 1 end end @@ -403,34 +420,38 @@ buttons: {cancel: 'cancel', destructive: 'destructive', test1: 'test1', test2: 'test2'}, cancel: ->{ @touched = :cancel }, destructive: ->{ @touched = :destructive }, success: ->(button, index){ @touched, @touched_index = button, index }, ) - proper_wait 0.6 + proper_wait 0.5 end it 'should call block with :cancel when cancel button is pressed' do @alert.cancelButtonIndex.should == 3 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :cancel end it 'should call block with :destructive when destructive button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :destructive end it 'should call block with "test1" when first button is pressed' do @alert.firstOtherButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == :test1 @touched_index.should == @alert.firstOtherButtonIndex end it 'should call block with "test2" when second button is pressed' do @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex + 1, animated: false) + proper_wait 0.5 @touched.should == :test2 @touched_index.should == @alert.firstOtherButtonIndex + 1 end end @@ -442,33 +463,37 @@ @touched_index = nil @alert = UIActionSheet.alert('test', buttons: ['cancel', 'destructive', 'test1', 'test2'], success: ->(button, index){ @touched, @touched_index = button, index }, ) - proper_wait 0.6 + proper_wait 0.5 end it 'should not call block when cancel button is pressed' do @alert.cancelButtonIndex.should == 3 @alert.dismissWithClickedButtonIndex(@alert.cancelButtonIndex, animated: false) + proper_wait 0.5 @touched.should == nil end it 'should not call block when destructive button is pressed' do @alert.destructiveButtonIndex.should == 0 @alert.dismissWithClickedButtonIndex(@alert.destructiveButtonIndex, animated: false) + proper_wait 0.5 @touched.should == nil end it 'should call block with "test1" when first button is pressed' do @alert.firstOtherButtonIndex.should == 1 @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex, animated: false) + proper_wait 0.5 @touched.should == 'test1' @touched_index.should == @alert.firstOtherButtonIndex end it 'should call block with "test2" when second button is pressed' do @alert.dismissWithClickedButtonIndex(@alert.firstOtherButtonIndex + 1, animated: false) + proper_wait 0.5 @touched.should == 'test2' @touched_index.should == @alert.firstOtherButtonIndex + 1 end end