lib/calabash-cucumber/map.rb in calabash-cucumber-0.19.0 vs lib/calabash-cucumber/map.rb in calabash-cucumber-0.19.1
- old
+ new
@@ -80,24 +80,27 @@
operation_map = {
:method_name => method_name,
:arguments => method_args
}
- res = Map.new.http({:method => :post, :path => 'map'},
- {:query => query, :operation => operation_map})
- res = JSON.parse(res)
- if res['outcome'] != 'SUCCESS'
+ route = {:method => :post, :path => "map"}
+ parameters = {:query => query,
+ :operation => operation_map}
+ body = self.map_factory.http(route, parameters)
+
+ hash = JSON.parse(body)
+ if hash["outcome"] != "SUCCESS"
message = %Q[
map #{query}, #{method_name} failed for:
- reason: #{res["reason"]}
-details: #{res["details"]}
+ reason: #{hash["reason"]}
+details: #{hash["details"]}
]
- Map.new.screenshot_and_raise(message)
+ self.map_factory.screenshot_and_raise(message)
end
- res
+ hash
end
# Asserts the result of a calabash `map` call and raises an error with
# `msg` if no valid results are found.
#
@@ -136,9 +139,15 @@
def self.assert_map_results(map_results, msg)
compact = map_results.compact
if compact.empty? or compact.member? '<VOID>' or compact.member? '*****'
Map.new.screenshot_and_raise msg
end
+ end
+
+ private
+
+ def self.map_factory
+ Map.new
end
end
end
end