Rename webpaste-paste-text and webpaste-paste-text-to-provider to be in "private scope"

master
Elis Axelsson 9 years ago
parent 8d5e884eca
commit 26f089e072
No known key found for this signature in database
GPG Key ID: D57EFA625C9A925F
  1. 16
      tests/integration/test-webpaste-providers.el
  2. 6
      tests/unit/test-webpaste-error-lambdas.el
  3. 18
      tests/unit/test-webpaste-paste-region-and-buffer.el
  4. 12
      tests/unit/test-webpaste-paste-text.el
  5. 18
      webpaste.el

@ -11,7 +11,7 @@
(before-each
;; Block requests
(spy-on 'webpaste-paste-text)
(spy-on 'webpaste--paste-text)
(spy-on 'webpaste--return-url))
(it
@ -24,7 +24,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)
(expect (spy-calls-most-recent 'webpaste--return-url)
:to-equal
@ -43,7 +43,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)
(expect (spy-calls-most-recent 'webpaste--return-url)
:to-equal
@ -62,7 +62,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)))
(it
@ -75,7 +75,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)))
(it
@ -88,7 +88,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)))
(it
@ -104,7 +104,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0)))
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0)))
(it
@ -117,7 +117,7 @@
:sync t)
(expect (spy-calls-count 'webpaste--return-url) :to-equal 1)
(expect (spy-calls-count 'webpaste-paste-text) :to-equal 0))))
(expect (spy-calls-count 'webpaste--paste-text) :to-equal 0))))
;;; test-webpaste-providers.el ends here

@ -10,7 +10,7 @@
"Create lambdas to use on failures, "
(before-each
(spy-on 'webpaste-paste-text)
(spy-on 'webpaste--paste-text)
(spy-on 'message))
(it
@ -24,7 +24,7 @@
"Got error: %S"
"my error")
(expect 'webpaste-paste-text
(expect 'webpaste--paste-text
:to-have-been-called-with
"my text")))
@ -38,7 +38,7 @@
"Got error: %S"
"my error")
(expect 'webpaste-paste-text
(expect 'webpaste--paste-text
:not :to-have-been-called))))

@ -10,7 +10,7 @@
"Don't to paste region or buffer because of wrong answer to question"
(before-each
(spy-on 'webpaste-paste-text)
(spy-on 'webpaste--paste-text)
(spy-on 'yes-or-no-p :and-return-value nil)
(setq webpaste-paste-confirmation t))
@ -22,18 +22,18 @@
;; Paste buffer
(webpaste-paste-buffer)
(expect 'webpaste-paste-text :not :to-have-been-called)
(expect 'webpaste--paste-text :not :to-have-been-called)
;; Paste region
(webpaste-paste-region 10 100)
(expect 'webpaste-paste-text :not :to-have-been-called)))
(expect 'webpaste--paste-text :not :to-have-been-called)))
(describe
"Paste region or buffer because of correct answer to question"
(before-each
(spy-on 'webpaste-paste-text)
(spy-on 'webpaste--paste-text)
(spy-on 'yes-or-no-p :and-return-value t)
(setq webpaste-paste-confirmation t))
@ -49,11 +49,11 @@
;; Paste buffer
(webpaste-paste-buffer)
(expect 'webpaste-paste-text :to-have-been-called-with (buffer-string))
(expect 'webpaste--paste-text :to-have-been-called-with (buffer-string))
;; Paste region
(webpaste-paste-region 10 100)
(expect 'webpaste-paste-text
(expect 'webpaste--paste-text
:to-have-been-called-with
(buffer-substring 10 100)))))
@ -62,7 +62,7 @@
"Paste region and buffer without question being asked"
(before-each
(spy-on 'webpaste-paste-text))
(spy-on 'webpaste--paste-text))
(it
"can paste entire buffers or regions"
@ -72,11 +72,11 @@
;; Paste buffer
(webpaste-paste-buffer)
(expect 'webpaste-paste-text :to-have-been-called-with (buffer-string))
(expect 'webpaste--paste-text :to-have-been-called-with (buffer-string))
;; Paste region
(webpaste-paste-region 10 100)
(expect 'webpaste-paste-text
(expect 'webpaste--paste-text
:to-have-been-called-with
(buffer-substring 10 100)))))

@ -17,7 +17,7 @@
'("provider1" "provider2"))
;; Don't allow it to try to paste, just fake it
(spy-on 'webpaste-paste-text-to-provider)
(spy-on 'webpaste--paste-text-to-provider)
;; And let tested list be resetted for each test
(setq webpaste-tested-providers nil))
@ -27,19 +27,19 @@
"can paste text to provider and try second provider if called again"
;; Let's paste to first provider
(webpaste-paste-text "my test text")
(webpaste--paste-text "my test text")
;; And check it was to first provider
(expect 'webpaste-paste-text-to-provider
(expect 'webpaste--paste-text-to-provider
:to-have-been-called-with
"my test text"
"provider1")
;; Let's paste to second provider
(webpaste-paste-text "my test text")
(webpaste--paste-text "my test text")
;; And check it was to second provider
(expect 'webpaste-paste-text-to-provider
(expect 'webpaste--paste-text-to-provider
:to-have-been-called-with
"my test text"
"provider2")
@ -59,7 +59,7 @@
(it
"can get the lambda for the specified provider and run it"
(expect (webpaste-paste-text-to-provider "my test text" "provider2")
(expect (webpaste--paste-text-to-provider "my test text" "provider2")
:to-equal
"my test text")))

@ -196,7 +196,7 @@ precalculated, and also available both for pre and post request access.")
"Predefined error callback for providers that always does failover."
(cl-function (lambda (&key error-thrown &allow-other-keys)
(message "Got error: %S" error-thrown)
(webpaste-paste-text text))))
(webpaste--paste-text text))))
(cl-defun webpaste-providers-error-lambda-no-failover (&key text)
@ -422,18 +422,15 @@ Optional params:
;; Return URL instead of nil
returned-url)
;;;###autoload
(cl-defun webpaste-paste-text-to-provider (text provider-name)
(cl-defun webpaste--paste-text-to-provider (text provider-name)
"Paste TEXT to specific PROVIDER-NAME.
This function sends a paste to a spacific provider. This function is created to
make `webpaste-paste-text' do less magic things all at once."
make `webpaste--paste-text' do less magic things all at once."
(funcall (webpaste--get-provider-by-name provider-name) text))
;;;###autoload
(cl-defun webpaste-paste-text (text)
(cl-defun webpaste--paste-text (text)
"Paste TEXT to some paste service.
If webpaste-provider-priority isn't populated, it will populate it with the
default providers.
@ -459,8 +456,9 @@ When we run out of providers to try, it will restart since
(setq webpaste--tested-providers (cdr webpaste--tested-providers))
;; Run pasting function
(webpaste-paste-text-to-provider text provider-name)))
(webpaste--paste-text-to-provider text provider-name)))
;;;###autoload
(cl-defun webpaste-paste-region (point mark)
@ -473,7 +471,7 @@ Argument MARK Current mark."
(unless (and webpaste-paste-confirmation
(not (yes-or-no-p "paste entire region?")))
;; Extract the buffer contents with buffer-substring and paste it
(webpaste-paste-text (buffer-substring point mark))))
(webpaste--paste-text (buffer-substring point mark))))
;;;###autoload
@ -485,7 +483,7 @@ Argument MARK Current mark."
(unless (and webpaste-paste-confirmation
(not (yes-or-no-p "paste entire buffer?")))
;; Extract the buffer contents with buffer-substring and paste it
(webpaste-paste-text (buffer-substring (point-min) (point-max)))))
(webpaste--paste-text (buffer-substring (point-min) (point-max)))))

Loading…
Cancel
Save