class Cuesmash::Start
For information on how this class works see the thor documentation github.com/erikhuda/thor/wiki
Public Instance Methods
android_appium_text()
click to toggle source
Android Appium text file set up
# File lib/cuesmash/start.rb, line 247 def android_appium_text appium = Cuesmash::AndroidAppiumText.new(platform_name: @config['platform'], avd: @config['devices']['emulators'].first, app: @app.app_path, new_command_timeout: @config['default']['test_timeout'].to_s) appium.execute end
build()
click to toggle source
# File lib/cuesmash/start.rb, line 148 def build # get the cuesmash.yml config @config = load_config # if no default then bail if @config['default'].nil? say 'add a default device and os version to the .cuesmash.yml', :red return end unless @config['mock_server_conf'].nil? mock_server = JsonConf.new(app_path: @config['mock_server_conf']['path'], file_name: @config['mock_server_conf']['name'], port: @config['mock_server_conf']['port']) mock_server.execute end if @config['platform'] == 'iOS' setup_ios(device: @config['default']['udid']) elsif @config['platform'] == 'Android' say 'Setting up android' setup_android else say "please set platform: 'iOS' or 'Android' in your .cuesmash.yml file", :red return end say "\nYour build is available at #{@app.app_path}", :green end
init()
click to toggle source
# File lib/cuesmash/start.rb, line 23 def init Cuesmash::Setup.setup end
ios_appium_text()
click to toggle source
iOS Appium text file set up
# File lib/cuesmash/start.rb, line 234 def ios_appium_text appium = Cuesmash::AppiumText.new(platform_name: 'iOS', device_name: @config['default']['device_name'], platform_version: @config['default']['platform_version'].to_s, app: @app.app_path, new_command_timeout: @config['default']['test_timeout'].to_s, udid: @config['default']['udid']) appium.execute end
load_config()
click to toggle source
load up the .cuesmash.yml config. If we don't find one then bail
@return [YAML] yaml loaded from the config_file
# File lib/cuesmash/start.rb, line 184 def load_config if File.exist?(CONFIG_FILE) config = YAML.load_file(CONFIG_FILE) if File.exist?(CONFIG_FILE) else say "There is no '.cuesmash.yml' file. Please create one and try again.\n", :red return end config end
setup_android()
click to toggle source
helper method for setting up android build
# File lib/cuesmash/start.rb, line 219 def setup_android @app = Cuesmash::AndroidApp.new(project_name: options[:app_name], build_configuration: @config['build_configuration']) # Compile the project compiler = Cuesmash::AndroidCompiler.new(project_name: options[:app_name], build_configuration: @config['build_configuration']) compiler.compile android_appium_text end
setup_ios(device: nil)
click to toggle source
helper method to setup and compile the iOS app
@param [string] device: nil <the UDID of the device to run on or nil if running on simulator>
# File lib/cuesmash/start.rb, line 199 def setup_ios(device: nil) @app = IosApp.new(file_name: options[:scheme].join(' '), build_configuration: @config['build_configuration'], app_name: @config['app_name'], device: device) # Compile the project compiler = Cuesmash::IosCompiler.new(scheme: options[:scheme].join(' '), tmp_dir: @app.tmp_dir, build_configuration: @config['build_configuration'], device: device, device_name: @config['default']['device_name']) compiler.compile ios_appium_text end
test()
click to toggle source
# File lib/cuesmash/start.rb, line 54 def test # get the cuesmash.yml config @config = load_config unless @config['mock_server_conf'].nil? mock_server = JsonConf.new(app_path: @config['mock_server_conf']['path'], file_name: @config['mock_server_conf']['name'], port: @config['mock_server_conf']['port']) mock_server.execute end # Compile the project if @config['platform'] == 'iOS' # enumerate over each device / OS combination and run the tests. @config['devices'].each do |device, oses| oses.each do |device_name, ios_udid| setup_ios(device: ios_udid) case when ios_udid.nil? say "\n============================\ntesting iOS #{device_name} on #{device}", :green Cuesmash::Command.execute(device: device, device_name: device_name, scheme: options[:scheme], tags: options[:tags], debug: options[:debug], app: @app, profile: options[:profile], quiet: options[:quiet], timeout: @config['default']['test_timeout'].to_s) else say "\n============================\ntesting iOS #{device_name} on #{device}", :green Cuesmash::Command.execute(device: device, device_name: device_name, scheme: options[:scheme], tags: options[:tags], debug: options[:debug], app: @app, profile: options[:profile], quiet: options[:quiet], timeout: @config['default']['test_timeout'].to_s, ios_udid: ios_udid) end # case end # os each end # device each # clean up the temp dir Logger.info "Cleaning up tmp dir\n" FileUtils.remove_entry @app.tmp_dir elsif @config['platform'] == 'Android' say 'Setting up android', :red @app = Cuesmash::AndroidApp.new(project_name: options[:app_name], build_configuration: @config['build_configuration']) setup_android # enumerate over each device / OS combination and run the tests. if @config['devices']['emulators'].first.nil? Cuesmash::AndroidCommand.execute(avd: @config['devices']['emulators'].first, server: options[:server], tags: options[:tags], debug: options[:debug], app: @app, profile: options[:profile], quiet: options[:quiet], timeout: @config['default']['test_timeout'].to_s) else @config['devices']['emulators'].each do |emulator| say "\n============================\ntesting Android on #{emulator}", :green Cuesmash::AndroidCommand.execute(avd: emulator, server: options[:server], tags: options[:tags], debug: options[:debug], app: @app, profile: options[:profile], quiet: options[:quiet], timeout: @config['default']['test_timeout'].to_s) end # device each end else say "please set platform: 'iOS' or 'Android' in your .cuesmash.yml file", :red return end end