You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2020/06/07 19:34:18 UTC
[whimsy] branch master updated: Extra helper methods
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 46f3653 Extra helper methods
46f3653 is described below
commit 46f3653ef1b5e1cbe9a18c232dd96a6110df2db2
Author: Sebb <se...@apache.org>
AuthorDate: Sun Jun 7 20:34:10 2020 +0100
Extra helper methods
---
lib/spec/spec_helper.rb | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb
index de352e3..e9f74bd 100644
--- a/lib/spec/spec_helper.rb
+++ b/lib/spec/spec_helper.rb
@@ -34,3 +34,31 @@ end
def fixture_path(*path)
File.join SPEC_ROOT, 'fixtures', path
end
+
+# run _json code and return [return code, target]
+def _json(&block)
+ # TODO: This is a bit of a hack
+ js = Wunderbar::JsonBuilder.new(Struct.new(:params).new({}))
+ js.log_level = :fatal
+ rc = nil
+ begin
+ rc = yield js
+ rescue Exception => e
+ js._exception(e)
+ end
+ [rc, js.target?]
+end
+
+# for testing code that needs credentials
+class ENV_
+ def initialize(user=nil, pass=nil)
+ @user = user || 'user'
+ @pass = pass || 'pass'
+ end
+ def user
+ @user
+ end
+ def password
+ @pass
+ end
+end