Module: FWToolkit::Test::ModelHelpers
- Defined in:
- lib/fwtoolkit/test/model_helper.rb
Instance Method Summary collapse
- #fwt_app_exec(method_name, *method_args) ⇒ Object
- #fwt_app_path ⇒ Object
- #fwt_ios_sdk ⇒ Object
- #fwt_kill_simulator ⇒ Object
- #fwt_launch_app(device = 'iphone') ⇒ Object
- #fwt_seed_app(model_names = []) ⇒ Object
- #fwt_seed_app_with_objects(objects = []) ⇒ Object
- #fwt_seed_app_with_pickle_models(model_names = []) ⇒ Object
- #fwt_set_user_defaults(bundle_identifier, user_defaults) ⇒ Object
- #fwt_simulator_applications_dir ⇒ Object
- #fwt_simulator_reset_data(sdk) ⇒ Object
Instance Method Details
#fwt_app_exec(method_name, *method_args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 9 def fwt_app_exec(method_name, *method_args) operation_map = Frank::Cucumber::Gateway.build_operation_map(method_name,method_args) res = frank_server.send_post( 'app_exec', :operation => operation_map ) return Frank::Cucumber::Gateway.evaluate_frankly_response( res, "app_exec #{method_name}" ) end |
#fwt_app_path ⇒ Object
42 43 44 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 42 def fwt_app_path ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH) end |
#fwt_ios_sdk ⇒ Object
37 38 39 40 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 37 def fwt_ios_sdk raise "IOS_SDK not defined. Please define this in your env.rb, i.e. IOS_SDK='5.1'" unless defined?(IOS_SDK) IOS_SDK end |
#fwt_kill_simulator ⇒ Object
24 25 26 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 24 def fwt_kill_simulator `echo 'application "iPhone Simulator" quit' | osascript` end |
#fwt_launch_app(device = 'iphone') ⇒ Object
33 34 35 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 33 def fwt_launch_app(device='iphone') launch_app fwt_app_path, fwt_ios_sdk, device end |
#fwt_seed_app(model_names = []) ⇒ Object
52 53 54 55 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 52 def fwt_seed_app(model_names=[]) puts "Deprecated: fwt_seed_app(). Please use fwt_seed_app_with_pickle_models(). Will be changed in 0.6.0 to accept objects." fwt_seed_app_with_pickle_models(model_names) end |
#fwt_seed_app_with_objects(objects = []) ⇒ Object
62 63 64 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 62 def fwt_seed_app_with_objects(objects = []) fwt_app_exec("seedCoreData:", objects.to_json) end |
#fwt_seed_app_with_pickle_models(model_names = []) ⇒ Object
57 58 59 60 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 57 def fwt_seed_app_with_pickle_models(model_names=[]) objects = model_names.collect{|n| model!(n)} fwt_seed_app_with_objects(objects) end |
#fwt_set_user_defaults(bundle_identifier, user_defaults) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 66 def fwt_set_user_defaults(bundle_identifier, user_defaults) app_dir = Dir.entries(fwt_simulator_applications_dir) app_dir.delete "." app_dir.delete ".." plist_file = File.join(fwt_simulator_applications_dir, app_dir.first, 'Library', 'Preferences', "#{bundle_identifier}.plist") plist = CFPropertyList::List.new(:file => plist_file) data = CFPropertyList.native_types(plist.value) data.merge! user_defaults plist.value = CFPropertyList.guess(data) plist.save(plist_file, CFPropertyList::List::FORMAT_BINARY) end |
#fwt_simulator_applications_dir ⇒ Object
20 21 22 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 20 def fwt_simulator_applications_dir File.join(Dir.home, 'Library', 'Application Support', 'iPhone Simulator', fwt_ios_sdk, 'Applications') end |
#fwt_simulator_reset_data(sdk) ⇒ Object
28 29 30 31 |
# File 'lib/fwtoolkit/test/model_helper.rb', line 28 def fwt_simulator_reset_data(sdk) fwt_kill_simulator FileUtils.rm_rf(fwt_simulator_applications_dir) end |