lib/fwtoolkit/test/model_helper.rb in fwtoolkit-0.3.4 vs lib/fwtoolkit/test/model_helper.rb in fwtoolkit-0.4.0
- old
+ new
@@ -1,86 +1,24 @@
-require 'mimic'
-require 'socket'
-require 'net/http'
require 'json'
-require 'erb'
require 'frank-cucumber/gateway'
-require 'pickle/world'
require 'cfpropertylist'
module FWToolkit
module Test
module ModelHelpers
- def mimic_server(port=11988)
- @mimic = Mimic.mimic(:port => port) unless @mimic
- @mimic
- end
-
- # todo: remove default response_content_type
- def queue_mimic_get_response(path, content, response_content_type = 'application/xml')
- mimic_server.get(path).returning(content, 200, {'Content-Type' => response_content_type})
- end
-
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
-
- def fwt_template_response(template_file_name, capture_models = [], options = nil)
-
- # probably should put some asserts in here
- # template_file_name should be single if capture_models.count == 0
- # template_file_name should be plural if capture_models.count > 0
- unless capture_models.empty?
- factory, name_or_index = *parse_model(capture_models[0])
- unless template_file_name
- template_file_name = factory.pluralize
- end
-
- objects = []
- capture_models.each do |capture_model|
- objects << model!(capture_model)
- end
-
- eval("@#{factory.pluralize} = objects")
- eval("@#{factory} = objects.first")
- end
-
- if options
- options.each do |option|
- key, value = option.split(":")
- eval("@#{key} = value")
- end
- end
-
- template_file = File.join(Dir.pwd, 'Frank', 'features', 'support', 'templates', "#{template_file_name}.erb")
- erb = ERB.new(File.open(template_file).read, 0,"")
- result = erb.result(binding)
- # cleanup
- unless capture_models.empty?
- eval("@#{factory.pluralize} = nil")
- eval("@#{factory} = nil")
- end
-
- if options
- options.each do |option|
- key, value = option.split(":")
- eval("@#{key} = nil")
- end
- end
-
- result
- end
-
def fwt_simulator_applications_dir
File.join(Dir.home, 'Library', 'Application Support', 'iPhone Simulator', fwt_ios_sdk, 'Applications')
end
def fwt_kill_simulator
@@ -128,14 +66,6 @@
end
end
end
end
-World(FWToolkit::Test::ModelHelpers)
-
-Before do |scenario|
- fwt_simulator_reset_data(fwt_ios_sdk)
-end
-
-After do |scenario|
- Mimic.cleanup!
-end
+World(FWToolkit::Test::ModelHelpers)
\ No newline at end of file