Permalink
Browse files

get-client-options -rename-> web-client-options, made private

  • Loading branch information...
1 parent 7956f67 commit e03279e4d78c771411ae0d2cdb10a477bff10648 @devn committed Dec 26, 2013
Showing with 28 additions and 9 deletions.
  1. +11 −7 src/yokogiri/core.clj
  2. +17 −2 test/yokogiri/test/core.clj
View
18 src/yokogiri/core.clj
@@ -6,10 +6,9 @@
(set! *warn-on-reflection* true)
-(defn get-client-options
+(defn- web-client-options
"Returns the client options object for a WebClient."
- [^WebClient client]
- (.getOptions client))
+ [^WebClient client] (.getOptions client))
(def set-client-options-map
'{:activex-native #(.setActiveXNative %1 %2)
@@ -31,16 +30,21 @@
"Sets options on the client. See
yokogiri.core/set-client-options-map for available options."
[^WebClient client opts]
- (let [^WebClientOptions client-opts (get-client-options client)]
+ (let [^WebClientOptions client-opts (web-client-options client)]
(doseq [[k v] opts]
(let [setter-fn (get set-client-options-map k)]
(setter-fn client-opts v)))
client))
-(defn get-client-options-map
- "Returns a map of all options currently set on the client."
+(defn get-client-options
+ "Returns a map of all options currently set on a client.
+
+ Usage:
+ user> (let [client (make-client :redirects false)]
+ (get-client-options client))
+ ;=> {:javascript true, :redirects false, ...}"
[^WebClient client]
- (let [^WebClientOptions opts (get-client-options ^WebClient client)]
+ (let [^WebClientOptions opts (web-client-options ^WebClient client)]
{:activex-native (. opts isActiveXNative)
:applet (. opts isAppletEnabled)
:block-popups (. opts isPopupBlockerEnabled)
View
19 test/yokogiri/test/core.clj
@@ -2,5 +2,20 @@
(:use [yokogiri.core])
(:use [midje.sweet]))
-(facts "about clients"
- (make-client) => truthy)
+(facts "yokogiri.core/make-client"
+ (fact "It can create a client"
+ (let [simple-client (make-client)]
+ simple-client => truthy
+ (class simple-client) => com.gargoylesoftware.htmlunit.WebClient))
+ (fact "It can create a client with options"
+ (let [insecure-client (make-client :insecure-ssl true)]
+ (:insecure-ssl (get-client-options insecure-client)) => true))
+ (fact "It can create a client with many non-default options"
+ (let [c (make-client :insecure-ssl false
+ :javascript false
+ :css false)
+ opts (get-client-options c)]
+ (->> (-> opts
+ (select-keys [:insecure-ssl :javascript :css])
+ (vals))
+ (every? false?))) => true))

0 comments on commit e03279e

Please sign in to comment.