Skip to content

Commit

Permalink
Update rspec and add shake trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Jun 18, 2014
1 parent b0f4cc7 commit b716174
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ source 'https://rubygems.org'
gem 'rake'

# Add your dependencies here:
gem 'rspec'
gem 'rspec-core'
gem 'appium_lib'
gem 'sugarcube', :require => 'sugarcube-classic'
26 changes: 26 additions & 0 deletions app/controllers/main_menu_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,30 @@ def data
'Gestures -- Visual'
]
end

attr_accessor :shaked
def shaked?
@shaked
end

def viewWillAppear(animated)
super
becomeFirstResponder
end

def viewDidDisappear(animated)
super
resignFirstResponder
end

def canBecomeFirstResponder
true
end

def motionEnded(motion, withEvent:event)
@shaked = motion == UIEventSubtypeMotionShake
alert = UIAlertView.new
alert.message = "Hello World!"
alert.show
end
end
15 changes: 15 additions & 0 deletions app/controllers/scrolling_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def viewDidLoad

# table view
@table = UITableView.alloc.initWithFrame(self.view.bounds)
@table.accessibilityLabel = "Scrolling Table View"
@table.autoresizingMask = UIViewAutoresizingFlexibleHeight
@table.backgroundColor = UIColor.whiteColor
@table.dataSource = @table.delegate = self
Expand All @@ -29,6 +30,20 @@ def viewDidLoad
@table.addGestureRecognizer(tapR)

@data = ('A'..'Z').to_a

# upSR = UISwipeGestureRecognizer.alloc.initWithTarget(self, action:"handle_swipe:")
# upSR.direction = UISwipeGestureRecognizerDirectionUp
# @table.addGestureRecognizer(upSR)

# downSR = UISwipeGestureRecognizer.alloc.initWithTarget(self, action:"handle_swipe:")
# downSR.direction = UISwipeGestureRecognizerDirectionDown
# @table.addGestureRecognizer(downSR)
end

def handle_swipe
alert = UIAlertView.new
alert.message = "Hello World!"
alert.show
end

def handle_tap
Expand Down
31 changes: 25 additions & 6 deletions spec/sanity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@

require 'rspec'

APP_PATH = '../build/iPhoneSimulator-7.0-Development/AppiumDemo.app'
APP_PATH = '../build/iPhoneSimulator-7.1-Development/AppiumDemo.app'

RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
end

def desired_caps
{
'platformName' => 'iOS',
'deviceName' => 'iPhone Retina (4-inch)', # 'iPhone Simulator 4-inch',
'platformVersion' => '6.1',
'platformVersion' => '7.1',
'app' => absolute_app_path
}
end

def absolute_app_path
File.join(File.dirname(__FILE__), APP_PATH)
f = File.join(File.dirname(__FILE__), APP_PATH)
puts f
f
end

def server_url
Expand All @@ -50,6 +58,17 @@ def server_url
driver_quit
end

it "should be able to shake" do
shake
find_element(:accessibility_id, 'Hello World!')
end

it "should be able to shake" do
# find_element(:accessibility_id, "Editing")
shake
# find_element(:accessibility_id, 'Hello World!')
end

describe "Handling UITextFields" do
it "should be able to fill in text fields" do
rnd = Random.new
Expand All @@ -62,19 +81,19 @@ def server_url
sum_el.text.should eq ""

add_btn = find_element(:name, "Add")
add_btn.enabled?.should be_false
add_btn.should_not be_enabled

el = find_element(:name, "TextField 1")
el.send_keys("#{n1}")

sum_el.text.should eq ""
add_btn.enabled?.should be_false
add_btn.should_not be_enabled

el = find_element(:name, "TextField 2")
el.send_keys("#{n2}")

sum_el.text.should eq ""
add_btn.enabled?.should be_true
add_btn.should be_enabled

add_btn.click

Expand Down

0 comments on commit b716174

Please sign in to comment.