lib/calabash.rb in calabash-2.0.0.pre11 vs lib/calabash.rb in calabash-2.0.0.prelegacy
- old
+ new
@@ -1,20 +1,16 @@
-# Calabash is a mobile automation tool used for automatic UI-testing.
-# It supports Android and iOS, both native and hybrid app testing.
+# Calabash is a Behavior-driven development (BDD) framework for Android and
+# iOS. It supports both native and hybrid app testing.
#
# It is developed and maintained by Xamarin and is released under the Eclipse
# Public License.
module Calabash
- class RequiredBothPlatformsError < LoadError
- end
-
require 'calabash/version'
require 'calabash/environment'
require 'calabash/logger'
require 'calabash/color'
require 'calabash/utility'
- require 'calabash/retry'
require 'calabash/application'
require 'calabash/device'
require 'calabash/http'
require 'calabash/server'
require 'calabash/wait'
@@ -26,15 +22,13 @@
require 'calabash/location'
require 'calabash/orientation'
require 'calabash/query'
require 'calabash/text'
require 'calabash/interactions'
- require 'calabash/web'
require 'calabash/defaults'
require 'calabash/legacy'
require 'calabash/console_helpers'
- require 'calabash/internal'
require 'calabash/patch'
Calabash::Patch.apply_patches!
@@ -46,11 +40,10 @@
include Calabash::LifeCycle
include Calabash::Location
include Calabash::Orientation
include Calabash::Text
include Calabash::Interactions
- include Calabash::Web
extend Calabash::Defaults
require 'calabash/page'
# Instantiate a page object for the current platform.
@@ -59,13 +52,13 @@
# examples for details.
#
# @example
# # android/pages/my_page.rb
# class Android::MyPage < Calabash::Page
- # def method
- # # [...]
- # end
+ # include Calabash::Android
+ #
+ # # [...]
# end
#
# # step definition
# Given(/[...]/) do
# # Calabash will determine your platform and pick the Android page.
@@ -76,11 +69,11 @@
# # This example shows page code sharing across iOS and Android
# # Please see the sample 'shared-page-logic' for details.
# # pages/abstract_login_page.rb
# class AbstractLoginPage < Calabash::Page
# def login(username, password)
- # cal.enter_text_in(username_field, username)
+ # enter_text_in(username_field, username)
# # [...]
# end
#
# private
#
@@ -89,10 +82,12 @@
# end
# end
#
# # pages/android_login_page.rb
# class Android::LoginPage < SharedLoginPage
+ # include Calabash::Android
+ #
# private
#
# def username_field
# "* marked:'a_username'"
# end
@@ -125,24 +120,19 @@
page_class = platform_module.const_get(page_name, false)
if page_class.is_a?(Class)
modules = page_class.included_modules.map(&:to_s)
- if modules.include?("Calabash::#{platform_module}")
- Logger.warn("Page '#{page_class}' includes Calabash::#{platform_module}. It is recommended not to include Calabash.")
- Logger.warn("Use cal.<method> for cross-platform methods, cal_android.<method> for Android-only and cal_ios.<method> for iOS-only")
+ unless modules.include?("Calabash::#{platform_module}")
+ raise "Page '#{page_class}' does not include Calabash::#{platform_module}"
end
if modules.include?('Calabash::Android') &&
modules.include?('Calabash::IOS')
raise "Page '#{page_class}' includes both Calabash::Android and Calabash::IOS"
end
- unless page_class.ancestors.include?(Calabash::Page)
- raise "Page '#{page_class}' is not a Calabash::Page"
- end
-
page = page_class.send(:new, self)
if page.is_a?(Calabash::Page)
page
else
@@ -324,39 +314,6 @@
end
end
end
set_trace_func(trace_func)
-end
-
-# @!visibility private
-class CalabashMethodsInternal
- include ::Calabash
-end
-
-# @!visibility private
-class CalabashMethods < BasicObject
- include ::Calabash
-
- instance_methods.each do |method_name|
- define_method(method_name) do |*args, &block|
- ::CalabashMethodsInternal.new.send(method_name, *args, &block)
- end
- end
-end
-
-# Returns a object that exposes all of the public Calabash cross-platform API.
-# This method should *always* be used to access the Calabash API. By default,
-# all methods are executed using the default device and the default
-# application.
-#
-# For OS specific methods use {cal_android} and {cal_ios}
-#
-# All API methods are available with documentation in {Calabash}
-#
-# @see {Calabash}
-#
-# @return [Object] Instance responding to all cross-platform Calabash methods
-# in the API.
-def cal
- CalabashMethods.new
end