Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix encoding issue (force utf-8)

  • Loading branch information...
commit 2dd5ce97666dc6b81095bb062248c51a8fe5c927 1 parent b4a722a
@krukow krukow authored
View
8 calabash-cucumber/lib/calabash-cucumber/core.rb
@@ -188,7 +188,7 @@ def picker(opts={:query => "pickerView", :action => :texts})
{:titleForRow => i},
{:forComponent => comp}]).first
end
- texts[comp] << txt
+ texts[comp] << txt
end
end
texts
@@ -270,7 +270,7 @@ def record_end(file_name)
file_name = "#{file_name}_#{os}_#{device}.base64"
system("/usr/bin/plutil -convert binary1 -o _recording_binary.plist _recording.plist")
system("openssl base64 -in _recording_binary.plist -out #{file_name}")
- system("rm _recording.plist _recording_binary.plist")
+ system("rm _recording.plist _recording_binary.plist")
file_name
end
@@ -313,7 +313,9 @@ def http(options, data=nil)
options[:body] = data.to_json
end
end
- make_http_request(options)
+ res = make_http_request(options)
+ res.force_encoding("UTF-8")
+ res
end
View
2  calabash-cucumber/lib/calabash-cucumber/version.rb
@@ -1,6 +1,6 @@
module Calabash
module Cucumber
- VERSION = "0.9.94"
+ VERSION = "0.9.95"
FRAMEWORK_VERSION = "0.9.93"
end
end
View
8 calabash-jvm/src/calabash_jvm/env.clj
@@ -1,11 +1,13 @@
(ns calabash-jvm.env
(:require [clojure.tools.logging :as lg]))
-(defn- getenv [str] (System/getenv str))
+(defn getenv [str] (System/getenv str))
+
+(def ^:dynamic *os* (or (getenv "OS") "ios5"))
+(def ^:dynamic *idiom* (or (getenv "DEVICE") "iphone"))
(def ^:dynamic *endpoint*
- (or (getenv "DEVICE_ENDPOINT")
- "http://localhost:37265"))
+ (or (getenv "DEVICE_ENDPOINT") "http://localhost:37265"))
(defn resource
[path] (str *endpoint* "/" path))
View
89 calabash-jvm/src/calabash_jvm/http.clj
@@ -8,50 +8,69 @@
(:import (java.security KeyStore)
(org.apache.http.impl.conn.tsccm ThreadSafeClientConnManager)))
-(def ^:dynamic *conn-timeout* 60000)
-(def ^:dynamic *socket-timeout* 60000)
+(def ^:dynamic *conn-timeout* 10000)
+(def ^:dynamic *socket-timeout* 10000)
(defn- mk-conn-mgr
[]
(mgr/make-reusable-conn-manager {:timeout *conn-timeout*}))
-(def ^:private ^:dynamic *conn-mgr* (conn-mgr))
+(def ^:private ^:dynamic *conn-mgr* (mk-conn-mgr))
+
+
+(defn req
+ "Makes http according to spec, with json body"
+ ([spec] (req spec nil))
+ ([spec body]
+ (binding [mgr/*connection-manager* *conn-mgr*]
+ (let [http-method (ns-resolve 'clj-http.client (symbol (name (:method spec))))
+ uri (env/resource (:path spec))
+ http-spec (merge {:content-type :json
+ :socket-timeout *socket-timeout*
+ :conn-timeout *conn-timeout*
+ :retry-handler (fn [ex try-count http-context]
+ (println "Retrying on:" ex)
+ (<= try-count 2))}
+ spec)
+ param-key (if (= (:method spec) :get)
+ :query-params
+ :body)
+ rsp (http-method
+ uri
+ (if body
+ (assoc http-spec param-key (json/json-str body))
+ http-spec))]
+
+ (if (is-error? rsp)
+ (error rsp)
+ (:body rsp))))))
(defn op-map [op & args]
- (let [m {:method_name op}]
- (if args
- (merge m {:arguments args})
- m)))
-
-(declare error)
-
-
-(defn map*
- [endpoint query op & args]
- (binding [mgr/*connection-manager* *conn-mgr*]
- (let [body (json/json-str {:query query
- :operation (apply op-map op args)})
- rsp
- (client/post endpoint
- {:body body
- :content-type :json
- :socket-timeout *socket-timeout*
- :conn-timeout *conn-timeout*
- :accept :json
- :retry-handler (fn [ex try-count http-context]
- (println "Got:" ex)
- (if (> try-count 1) false true))
- :as :json})]
- (if (or
- (not= (:status rsp) 200)
- (not= (:outcome (:body rsp) "SUCCESS")))
- (error rsp)
- (:results (:body rsp))))))
-
-(defn cmap
+ {:method_name op
+ :arguments (or args [])})
+
+(declare error!)
+(declare is-error?)
+
+(defn map-views
+ "Reaches the map endpoint via POST.
+ Takes a UIQuery, and op name and optional args"
[query op & args]
- (apply map* (env/resource "map") query op args))
+ (:results (req {:method :post
+ :path "map"
+ :as :json}
+ {:query query
+ :operation (apply op-map op args)})))
+
+
+
+
+(defn- is-error?
+ [rsp]
+ (or
+ (>= (:status rsp) 400)
+ (not= (:outcome (:body rsp) "SUCCESS"))))
(defn- error
[{body :body}]
Please sign in to comment.
Something went wrong with that request. Please try again.