qwikdoc 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/CHANGES +3 -0
- data/COPYING +340 -0
- data/Gemfile +3 -0
- data/README.md +10 -0
- data/Rakefile +10 -0
- data/TextFormattingRules +137 -0
- data/TextFormattingRules.ja +143 -0
- data/bin/qwikdoc +34 -0
- data/lib/qwik_doc.rb +15 -0
- data/lib/qwik_doc/hack.rb +184 -0
- data/qwikdoc.gemspec +26 -0
- data/spec/qwik_doc_spec.rb +305 -0
- data/spec/spec_helper.rb +12 -0
- data/vendor/qwik/Makefile +63 -0
- data/vendor/qwik/Rakefile +17 -0
- data/vendor/qwik/act-aa.rb +83 -0
- data/vendor/qwik/act-archive.rb +386 -0
- data/vendor/qwik/act-attach.rb +304 -0
- data/vendor/qwik/act-backup.rb +236 -0
- data/vendor/qwik/act-basic.rb +325 -0
- data/vendor/qwik/act-book.rb +161 -0
- data/vendor/qwik/act-calc.rb +371 -0
- data/vendor/qwik/act-charset.rb +251 -0
- data/vendor/qwik/act-christel.rb +112 -0
- data/vendor/qwik/act-chronology.rb +149 -0
- data/vendor/qwik/act-code.rb +155 -0
- data/vendor/qwik/act-comment.rb +554 -0
- data/vendor/qwik/act-config.rb +49 -0
- data/vendor/qwik/act-counter.rb +125 -0
- data/vendor/qwik/act-day.rb +96 -0
- data/vendor/qwik/act-describe.rb +135 -0
- data/vendor/qwik/act-diary.rb +109 -0
- data/vendor/qwik/act-edit.rb +317 -0
- data/vendor/qwik/act-embed-html.rb +296 -0
- data/vendor/qwik/act-emode.rb +150 -0
- data/vendor/qwik/act-event.rb +187 -0
- data/vendor/qwik/act-file.rb +303 -0
- data/vendor/qwik/act-files.rb +771 -0
- data/vendor/qwik/act-getpass.rb +295 -0
- data/vendor/qwik/act-history.rb +136 -0
- data/vendor/qwik/act-html.rb +204 -0
- data/vendor/qwik/act-httpauth.rb +147 -0
- data/vendor/qwik/act-include.rb +142 -0
- data/vendor/qwik/act-interwiki.rb +189 -0
- data/vendor/qwik/act-isearch.rb +109 -0
- data/vendor/qwik/act-keywords.rb +137 -0
- data/vendor/qwik/act-lang.rb +81 -0
- data/vendor/qwik/act-license.rb +63 -0
- data/vendor/qwik/act-list.rb +287 -0
- data/vendor/qwik/act-login.rb +410 -0
- data/vendor/qwik/act-logout.rb +60 -0
- data/vendor/qwik/act-mail.rb +159 -0
- data/vendor/qwik/act-map.rb +292 -0
- data/vendor/qwik/act-md5.rb +42 -0
- data/vendor/qwik/act-mdlb.rb +741 -0
- data/vendor/qwik/act-media.rb +416 -0
- data/vendor/qwik/act-member.rb +157 -0
- data/vendor/qwik/act-menu.rb +142 -0
- data/vendor/qwik/act-metadata.rb +323 -0
- data/vendor/qwik/act-mlsubmitform.rb +49 -0
- data/vendor/qwik/act-monitor.rb +167 -0
- data/vendor/qwik/act-new.rb +418 -0
- data/vendor/qwik/act-pagelist.rb +248 -0
- data/vendor/qwik/act-password.rb +145 -0
- data/vendor/qwik/act-plan.rb +210 -0
- data/vendor/qwik/act-povray.rb +230 -0
- data/vendor/qwik/act-presen.rb +380 -0
- data/vendor/qwik/act-redirect.rb +133 -0
- data/vendor/qwik/act-ring.rb +1071 -0
- data/vendor/qwik/act-rrefs.rb +255 -0
- data/vendor/qwik/act-ruby.rb +116 -0
- data/vendor/qwik/act-sample.rb +170 -0
- data/vendor/qwik/act-save.rb +295 -0
- data/vendor/qwik/act-schedule.rb +374 -0
- data/vendor/qwik/act-search.rb +180 -0
- data/vendor/qwik/act-searchwords.rb +51 -0
- data/vendor/qwik/act-sendpass.rb +83 -0
- data/vendor/qwik/act-site.rb +89 -0
- data/vendor/qwik/act-sitebackup.rb +419 -0
- data/vendor/qwik/act-sitelog.rb +118 -0
- data/vendor/qwik/act-smil.rb +299 -0
- data/vendor/qwik/act-status.rb +220 -0
- data/vendor/qwik/act-style.rb +608 -0
- data/vendor/qwik/act-table.rb +263 -0
- data/vendor/qwik/act-tableform.rb +241 -0
- data/vendor/qwik/act-tag.rb +103 -0
- data/vendor/qwik/act-text.rb +70 -0
- data/vendor/qwik/act-textarea.rb +164 -0
- data/vendor/qwik/act-theme.rb +346 -0
- data/vendor/qwik/act-toc.rb +112 -0
- data/vendor/qwik/act-typekey.rb +198 -0
- data/vendor/qwik/act-under-const.rb +94 -0
- data/vendor/qwik/act-webservice.rb +321 -0
- data/vendor/qwik/act-wema.rb +558 -0
- data/vendor/qwik/act-wysiwyg.rb +238 -0
- data/vendor/qwik/action.rb +325 -0
- data/vendor/qwik/autoreload.rb +98 -0
- data/vendor/qwik/bench-bench.rb +28 -0
- data/vendor/qwik/bench-emode.rb +47 -0
- data/vendor/qwik/bench-format-xml.rb +70 -0
- data/vendor/qwik/bench-large-table.rb +62 -0
- data/vendor/qwik/bench-md5.rb +14 -0
- data/vendor/qwik/bench-module-session.rb +19 -0
- data/vendor/qwik/bench-page.rb +50 -0
- data/vendor/qwik/bench-s-md5.rb +28 -0
- data/vendor/qwik/bench-session.rb +25 -0
- data/vendor/qwik/bench-textformat.rb +31 -0
- data/vendor/qwik/catalog-factory.rb +91 -0
- data/vendor/qwik/catalog-ja.rb +479 -0
- data/vendor/qwik/catalog-ml-ja.rb +145 -0
- data/vendor/qwik/check-act-monitor.rb +112 -0
- data/vendor/qwik/check-act-monitor2.rb +46 -0
- data/vendor/qwik/check-act-theme.rb +27 -0
- data/vendor/qwik/check-event.rb +112 -0
- data/vendor/qwik/check-event2.rb +55 -0
- data/vendor/qwik/check-htree-rexml.rb +77 -0
- data/vendor/qwik/check-htree.rb +51 -0
- data/vendor/qwik/check-libxml.rb +135 -0
- data/vendor/qwik/check-many-pages.rb +47 -0
- data/vendor/qwik/check-monitor.rb +33 -0
- data/vendor/qwik/check-observer.rb +67 -0
- data/vendor/qwik/check-server.rb +61 -0
- data/vendor/qwik/check-uuencode.rb +33 -0
- data/vendor/qwik/check-webdav.rb +65 -0
- data/vendor/qwik/check-xml-xpath.rb +27 -0
- data/vendor/qwik/common-backtrace.rb +94 -0
- data/vendor/qwik/common-basic.rb +111 -0
- data/vendor/qwik/common-condition.rb +142 -0
- data/vendor/qwik/common-error.rb +48 -0
- data/vendor/qwik/common-gettext.rb +50 -0
- data/vendor/qwik/common-javascript.rb +45 -0
- data/vendor/qwik/common-notice.rb +132 -0
- data/vendor/qwik/common-plain.rb +105 -0
- data/vendor/qwik/common-plugin.rb +111 -0
- data/vendor/qwik/common-res.rb +76 -0
- data/vendor/qwik/common-resolve.rb +92 -0
- data/vendor/qwik/common-send.rb +171 -0
- data/vendor/qwik/common-session.rb +139 -0
- data/vendor/qwik/common-surface.rb +261 -0
- data/vendor/qwik/common-url.rb +90 -0
- data/vendor/qwik/compat/Makefile +12 -0
- data/vendor/qwik/compat/add_load_path.rb +1 -0
- data/vendor/qwik/config.rb +299 -0
- data/vendor/qwik/db-b-backup.rb +142 -0
- data/vendor/qwik/db-backup.rb +184 -0
- data/vendor/qwik/db-berkeley.rb +306 -0
- data/vendor/qwik/db-filesystem.rb +305 -0
- data/vendor/qwik/db-indexer.rb +154 -0
- data/vendor/qwik/db-searchwords.rb +238 -0
- data/vendor/qwik/description-ja.rb +267 -0
- data/vendor/qwik/description.rb +256 -0
- data/vendor/qwik/dev-add-copyright.rb +23 -0
- data/vendor/qwik/dev-backup.rb +24 -0
- data/vendor/qwik/dev-bench.rb +175 -0
- data/vendor/qwik/dev-calctime.rb +52 -0
- data/vendor/qwik/dev-css-compressor.rb +60 -0
- data/vendor/qwik/dev-extract-catalog.rb +102 -0
- data/vendor/qwik/dev-js-compressor.rb +73 -0
- data/vendor/qwik/dev-release.rb +235 -0
- data/vendor/qwik/dev-replace.rb +353 -0
- data/vendor/qwik/dev-sendmail.rb +25 -0
- data/vendor/qwik/farm.rb +283 -0
- data/vendor/qwik/gettext.rb +56 -0
- data/vendor/qwik/group-cond.rb +157 -0
- data/vendor/qwik/group-config.rb +247 -0
- data/vendor/qwik/group-confirm.rb +147 -0
- data/vendor/qwik/group-db.rb +326 -0
- data/vendor/qwik/group-mail.rb +195 -0
- data/vendor/qwik/group-member.rb +307 -0
- data/vendor/qwik/group-sendmail.rb +231 -0
- data/vendor/qwik/group-site.rb +374 -0
- data/vendor/qwik/group-sweep.rb +63 -0
- data/vendor/qwik/group.rb +157 -0
- data/vendor/qwik/helper.rb +6 -0
- data/vendor/qwik/html-generator.rb +104 -0
- data/vendor/qwik/html-to-wabisabi.rb +149 -0
- data/vendor/qwik/htree-diff.rb +87 -0
- data/vendor/qwik/htree-format-xml.rb +57 -0
- data/vendor/qwik/htree-generator.rb +144 -0
- data/vendor/qwik/htree-get.rb +251 -0
- data/vendor/qwik/htree-html-generator.rb +179 -0
- data/vendor/qwik/htree-template.rb +263 -0
- data/vendor/qwik/htree-to-wabisabi.rb +171 -0
- data/vendor/qwik/loadlib.rb +79 -0
- data/vendor/qwik/logger.rb +115 -0
- data/vendor/qwik/mail-body.rb +171 -0
- data/vendor/qwik/mail-header.rb +474 -0
- data/vendor/qwik/mail-multipart.rb +193 -0
- data/vendor/qwik/mail-parse.rb +147 -0
- data/vendor/qwik/mail.rb +341 -0
- data/vendor/qwik/mailaddress.rb +83 -0
- data/vendor/qwik/mdlb-model.rb +81 -0
- data/vendor/qwik/mdlb-sample.rb +324 -0
- data/vendor/qwik/ml-catalog-factory.rb +27 -0
- data/vendor/qwik/ml-exception.rb +15 -0
- data/vendor/qwik/ml-generator.rb +28 -0
- data/vendor/qwik/ml-gettext.rb +137 -0
- data/vendor/qwik/ml-logger.rb +82 -0
- data/vendor/qwik/ml-memory.rb +65 -0
- data/vendor/qwik/ml-msg-validator.rb +86 -0
- data/vendor/qwik/ml-processor.rb +609 -0
- data/vendor/qwik/ml-quickml-server.rb +122 -0
- data/vendor/qwik/ml-sendmail.rb +0 -0
- data/vendor/qwik/ml-server.rb +107 -0
- data/vendor/qwik/ml-session.rb +348 -0
- data/vendor/qwik/ml-sweeper.rb +101 -0
- data/vendor/qwik/mock-logger.rb +65 -0
- data/vendor/qwik/mock-sendmail.rb +78 -0
- data/vendor/qwik/mock-socket.rb +82 -0
- data/vendor/qwik/modulobe.rb +406 -0
- data/vendor/qwik/mongrel-server.rb +72 -0
- data/vendor/qwik/page-files.rb +249 -0
- data/vendor/qwik/page-generate.rb +82 -0
- data/vendor/qwik/page-get.rb +262 -0
- data/vendor/qwik/page-images.rb +168 -0
- data/vendor/qwik/page-put.rb +128 -0
- data/vendor/qwik/page-rrefs.rb +154 -0
- data/vendor/qwik/page-title.rb +0 -0
- data/vendor/qwik/page-wikidb.rb +234 -0
- data/vendor/qwik/page.rb +67 -0
- data/vendor/qwik/pages.rb +444 -0
- data/vendor/qwik/parse-plugin.rb +249 -0
- data/vendor/qwik/parser-emode.rb +116 -0
- data/vendor/qwik/parser-inline.rb +273 -0
- data/vendor/qwik/parser.rb +350 -0
- data/vendor/qwik/password.rb +183 -0
- data/vendor/qwik/periodic.rb +79 -0
- data/vendor/qwik/qp.rb +56 -0
- data/vendor/qwik/qwik-service.rb +341 -0
- data/vendor/qwik/qwik.rb +5 -0
- data/vendor/qwik/qwikweb-adduser.rb +34 -0
- data/vendor/qwik/qwikweb-catalog-validator.rb +110 -0
- data/vendor/qwik/qwikweb-incgen.rb +28 -0
- data/vendor/qwik/qwikweb-makesite.rb +41 -0
- data/vendor/qwik/qwikweb-server.rb +44 -0
- data/vendor/qwik/qwikweb-showpassword.rb +26 -0
- data/vendor/qwik/qwikweb-watchlog.rb +67 -0
- data/vendor/qwik/request-path.rb +304 -0
- data/vendor/qwik/request-ua.rb +76 -0
- data/vendor/qwik/request-webrick.rb +81 -0
- data/vendor/qwik/request.rb +91 -0
- data/vendor/qwik/resolve-tdiary.rb +292 -0
- data/vendor/qwik/resolve.rb +121 -0
- data/vendor/qwik/response.rb +228 -0
- data/vendor/qwik/server-memory.rb +57 -0
- data/vendor/qwik/server-webrick.rb +102 -0
- data/vendor/qwik/server.rb +252 -0
- data/vendor/qwik/site-config.rb +149 -0
- data/vendor/qwik/site-db.rb +136 -0
- data/vendor/qwik/site-event.rb +162 -0
- data/vendor/qwik/site-files.rb +86 -0
- data/vendor/qwik/site-group.rb +103 -0
- data/vendor/qwik/site-index.rb +47 -0
- data/vendor/qwik/site-log.rb +64 -0
- data/vendor/qwik/site-member.rb +230 -0
- data/vendor/qwik/site-monitor.rb +97 -0
- data/vendor/qwik/site-pages.rb +62 -0
- data/vendor/qwik/site-plan.rb +139 -0
- data/vendor/qwik/site-report.rb +282 -0
- data/vendor/qwik/site-resolve.rb +230 -0
- data/vendor/qwik/site-rrefs.rb +18 -0
- data/vendor/qwik/site-search.rb +180 -0
- data/vendor/qwik/site-timeline.rb +153 -0
- data/vendor/qwik/site-url.rb +189 -0
- data/vendor/qwik/site.rb +76 -0
- data/vendor/qwik/smil-time.rb +105 -0
- data/vendor/qwik/smtp-session.rb +331 -0
- data/vendor/qwik/template-generator.rb +149 -0
- data/vendor/qwik/template.rb +85 -0
- data/vendor/qwik/test-common.rb +10 -0
- data/vendor/qwik/test-ml-info.rb +225 -0
- data/vendor/qwik/test-module-ml.rb +142 -0
- data/vendor/qwik/test-module-path.rb +110 -0
- data/vendor/qwik/test-module-public.rb +70 -0
- data/vendor/qwik/test-module-server.rb +98 -0
- data/vendor/qwik/test-module-session.rb +264 -0
- data/vendor/qwik/test-module-suite.rb +91 -0
- data/vendor/qwik/test-ms-applemail.rb +59 -0
- data/vendor/qwik/test-ms-attach.rb +174 -0
- data/vendor/qwik/test-ms-basic.rb +40 -0
- data/vendor/qwik/test-ms-close.rb +35 -0
- data/vendor/qwik/test-ms-confirm.rb +75 -0
- data/vendor/qwik/test-ms-ignore-spam.rb +57 -0
- data/vendor/qwik/test-ms-japanese.rb +97 -0
- data/vendor/qwik/test-ms-jfilename.rb +82 -0
- data/vendor/qwik/test-ms-large.rb +58 -0
- data/vendor/qwik/test-ms-member.rb +103 -0
- data/vendor/qwik/test-ms-multipart.rb +84 -0
- data/vendor/qwik/test-ms-org.rb +129 -0
- data/vendor/qwik/test-ms-plan.rb +130 -0
- data/vendor/qwik/test-ms-post.rb +53 -0
- data/vendor/qwik/test-ms-quopri.rb +76 -0
- data/vendor/qwik/test-sub-quopri.rb +45 -0
- data/vendor/qwik/test-submit-base64.rb +59 -0
- data/vendor/qwik/test-submit-forward.rb +61 -0
- data/vendor/qwik/test-submit-html-mail.rb +52 -0
- data/vendor/qwik/test-submit-japanese.rb +135 -0
- data/vendor/qwik/test-submit-jfilename.rb +144 -0
- data/vendor/qwik/test-submit-uuencode.rb +71 -0
- data/vendor/qwik/test-suite-all.rb +8 -0
- data/vendor/qwik/test-suite-basic.rb +9 -0
- data/vendor/qwik/test-suite-ml.rb +9 -0
- data/vendor/qwik/test-typekey.rb +64 -0
- data/vendor/qwik/testunit.rb +45 -0
- data/vendor/qwik/tokenizer-inline.rb +294 -0
- data/vendor/qwik/tokenizer.rb +332 -0
- data/vendor/qwik/typekey.rb +160 -0
- data/vendor/qwik/util-basic.rb +135 -0
- data/vendor/qwik/util-charset.rb +332 -0
- data/vendor/qwik/util-css.rb +56 -0
- data/vendor/qwik/util-csv-tokenizer.rb +113 -0
- data/vendor/qwik/util-filename.rb +112 -0
- data/vendor/qwik/util-pathname.rb +202 -0
- data/vendor/qwik/util-pid.rb +58 -0
- data/vendor/qwik/util-safe.rb +67 -0
- data/vendor/qwik/util-sendmail.rb +273 -0
- data/vendor/qwik/util-string.rb +203 -0
- data/vendor/qwik/util-time.rb +125 -0
- data/vendor/qwik/util-webrick.rb +176 -0
- data/vendor/qwik/version.rb +11 -0
- data/vendor/qwik/wabisabi-basic.rb +163 -0
- data/vendor/qwik/wabisabi-diff.rb +130 -0
- data/vendor/qwik/wabisabi-format-xml.rb +310 -0
- data/vendor/qwik/wabisabi-generator.rb +262 -0
- data/vendor/qwik/wabisabi-index.rb +174 -0
- data/vendor/qwik/wabisabi-table.rb +212 -0
- data/vendor/qwik/wabisabi-template.rb +295 -0
- data/vendor/qwik/wabisabi-to-htree.rb +111 -0
- data/vendor/qwik/wabisabi-to-wiki.rb +690 -0
- data/vendor/qwik/wabisabi-traverse.rb +207 -0
- data/vendor/qwik/wabisabi-validator.rb +116 -0
- data/vendor/qwik/wabisabi.rb +5 -0
- metadata +416 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
require 'pp'
|
|
6
|
+
|
|
7
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
8
|
+
require 'qwik/testunit'
|
|
9
|
+
require 'qwik/test-module-path'
|
|
10
|
+
require 'qwik/test-module-session'
|
|
11
|
+
require 'qwik/test-module-public'
|
|
12
|
+
require 'qwik/mock-logger'
|
|
13
|
+
require 'qwik/mock-socket'
|
|
14
|
+
require 'qwik/mock-sendmail'
|
|
15
|
+
require 'qwik/config'
|
|
16
|
+
require 'qwik/ml-memory'
|
|
17
|
+
|
|
18
|
+
$quickml_debug = true
|
|
19
|
+
|
|
20
|
+
module QuickML
|
|
21
|
+
class Group
|
|
22
|
+
def setup_test_config
|
|
23
|
+
# setup config
|
|
24
|
+
raise 'config not defined' if !defined?($test_config)
|
|
25
|
+
@qwikconfig = $test_config
|
|
26
|
+
|
|
27
|
+
# setup memory
|
|
28
|
+
raise 'memory not defined' if !defined?($test_memory)
|
|
29
|
+
@qwikmemory = $test_memory
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module TestModuleML
|
|
35
|
+
include TestSession
|
|
36
|
+
include TestModulePublic
|
|
37
|
+
|
|
38
|
+
# ============================== setup
|
|
39
|
+
def setup
|
|
40
|
+
web_setup
|
|
41
|
+
ml_setup
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def ml_setup
|
|
45
|
+
# setup quickml config
|
|
46
|
+
if ! defined?($quickml_config) || $quickml_config.nil?
|
|
47
|
+
config = Qwik::Config.new
|
|
48
|
+
config[:logger] = QuickML::MockLogger.new
|
|
49
|
+
config.update(Qwik::Config::DebugConfig)
|
|
50
|
+
config.update(Qwik::Config::TestConfig)
|
|
51
|
+
QuickML::ServerMemory.init_mutex(config)
|
|
52
|
+
QuickML::ServerMemory.init_catalog(config)
|
|
53
|
+
|
|
54
|
+
$quickml_config = config
|
|
55
|
+
end
|
|
56
|
+
@ml_config = $quickml_config
|
|
57
|
+
dummy = @ml_config.logger.get_log # clear log
|
|
58
|
+
|
|
59
|
+
@ml_dir = @ml_config.sites_dir.path+'test'
|
|
60
|
+
@ml_dir.teardown
|
|
61
|
+
|
|
62
|
+
@ml_catalog = @ml_config.catalog
|
|
63
|
+
@ml_message_charset = 'iso-2022-jp'
|
|
64
|
+
|
|
65
|
+
t_make_public(QuickML::Group, :site_post)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# ============================== teardown
|
|
69
|
+
def teardown
|
|
70
|
+
ml_teardown
|
|
71
|
+
web_teardown
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def ml_teardown
|
|
75
|
+
@ml_dir.teardown if @ml_dir
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# ============================== session
|
|
79
|
+
def sendmail(from, to, subject, cc=nil)
|
|
80
|
+
message = yield
|
|
81
|
+
|
|
82
|
+
cc_line = ''
|
|
83
|
+
cc_line = "Cc: #{cc}\n" if cc
|
|
84
|
+
separator_line = ''
|
|
85
|
+
separator_line = "\n" unless /\n\z/ =~ message
|
|
86
|
+
|
|
87
|
+
contents = ''
|
|
88
|
+
contents << "To: #{to}\n"
|
|
89
|
+
contents << "From: #{from}\n"
|
|
90
|
+
contents << "Subject: #{subject}\n"
|
|
91
|
+
contents << cc_line
|
|
92
|
+
contents << separator_line
|
|
93
|
+
contents << message
|
|
94
|
+
|
|
95
|
+
inputs = "HELO localhost
|
|
96
|
+
MAIL FROM: #{from}
|
|
97
|
+
RCPT TO: #{to}
|
|
98
|
+
DATA
|
|
99
|
+
#{contents}
|
|
100
|
+
.
|
|
101
|
+
QUIT
|
|
102
|
+
"
|
|
103
|
+
inputs = inputs.set_sourcecode_charset.to_mail_charset
|
|
104
|
+
socket = QuickML::MockSocket.new(inputs)
|
|
105
|
+
c = @ml_config
|
|
106
|
+
session = QuickML::Session.new(c, c.logger, c.catalog, socket)
|
|
107
|
+
session.start
|
|
108
|
+
return socket.result
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def send_normal_mail(from)
|
|
112
|
+
sendmail(from, 'test@q.example.com', 'test') { 'test' }
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def unsubscribe(from)
|
|
116
|
+
sendmail(from, 'test@q.example.com', 'unsubscribe') { '' }
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def sm(sub, &b)
|
|
120
|
+
sendmail('bob@example.net', 'test@q.example.com', sub, &b)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# ============================== assert
|
|
124
|
+
def ok_log(e, range=nil)
|
|
125
|
+
logs = @ml_config.logger.get_log
|
|
126
|
+
logs = logs[range] if range
|
|
127
|
+
return ok_eq(e, logs) if e.is_a?(Array)
|
|
128
|
+
return ok_eq(e, logs.join("\n"))
|
|
129
|
+
end
|
|
130
|
+
alias ok ok_log
|
|
131
|
+
|
|
132
|
+
# ==================== backward compatibility
|
|
133
|
+
# def gen_mail(&b)
|
|
134
|
+
# return QuickML::Mail.generate(&b)
|
|
135
|
+
# end
|
|
136
|
+
|
|
137
|
+
def post_mail(group, &b)
|
|
138
|
+
mail = QuickML::Mail.generate(&b)
|
|
139
|
+
group.site_post(mail, true)
|
|
140
|
+
return mail
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
6
|
+
require 'qwik/util-pathname'
|
|
7
|
+
|
|
8
|
+
module Qwik
|
|
9
|
+
class Site
|
|
10
|
+
def erase_all
|
|
11
|
+
@pages.erase_all
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Pages
|
|
16
|
+
def erase_all
|
|
17
|
+
@db.erase_all
|
|
18
|
+
@pages = {}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class FileSystemDB
|
|
23
|
+
def erase_all
|
|
24
|
+
# do nothing
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# test-module-bdb
|
|
29
|
+
module BDBEraseAllModule
|
|
30
|
+
def bdb_erase_all(db)
|
|
31
|
+
begin
|
|
32
|
+
db.each {|k, v|
|
|
33
|
+
db[k] = nil
|
|
34
|
+
}
|
|
35
|
+
rescue Fatal => e
|
|
36
|
+
return if e.message == 'closed DB'
|
|
37
|
+
raise e
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class BerkeleyDB
|
|
43
|
+
include BDBEraseAllModule
|
|
44
|
+
|
|
45
|
+
def erase_all
|
|
46
|
+
@backupdb.erase_all
|
|
47
|
+
bdb_erase_all(@db)
|
|
48
|
+
@mtime_db.erase_all
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class BackupBDB
|
|
53
|
+
include BDBEraseAllModule
|
|
54
|
+
|
|
55
|
+
def erase_all
|
|
56
|
+
bdb_erase_all(@db)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class Pathname
|
|
62
|
+
def erase_all_for_test
|
|
63
|
+
self.each_entry {|file|
|
|
64
|
+
base = file.to_s
|
|
65
|
+
next if base == '.' || base == '..'
|
|
66
|
+
|
|
67
|
+
f = self + file
|
|
68
|
+
|
|
69
|
+
if f.directory?
|
|
70
|
+
f.erase_all_for_test # Recursive.
|
|
71
|
+
next
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if f.exist?
|
|
75
|
+
f.unlink
|
|
76
|
+
end
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def setup
|
|
81
|
+
self.teardown if self.directory?
|
|
82
|
+
self.check_directory
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def teardown
|
|
86
|
+
unless self.directory?
|
|
87
|
+
return
|
|
88
|
+
end
|
|
89
|
+
self.erase_all_for_test
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# test-module-bdb
|
|
93
|
+
def erase_db(f)
|
|
94
|
+
begin
|
|
95
|
+
erase_all_db(f)
|
|
96
|
+
rescue => e
|
|
97
|
+
return
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def erase_all_db(f)
|
|
102
|
+
return unless f.exist?
|
|
103
|
+
db = BDB::Hash.new(f.to_s, nil, 0)
|
|
104
|
+
db.each {|k, v|
|
|
105
|
+
db[k] = nil
|
|
106
|
+
}
|
|
107
|
+
db.close
|
|
108
|
+
end
|
|
109
|
+
private :erase_db, :erase_all_db
|
|
110
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
6
|
+
|
|
7
|
+
module TestModulePublic
|
|
8
|
+
def t_make_public(klass, *args)
|
|
9
|
+
args.each {|method_name|
|
|
10
|
+
klass.instance_eval {
|
|
11
|
+
public method_name
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def t_make_readable(klass, *args)
|
|
17
|
+
args.each {|variable_name|
|
|
18
|
+
klass.instance_eval {
|
|
19
|
+
attr_reader variable_name
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def t_make_writable(klass, *args)
|
|
25
|
+
args.each {|variable_name|
|
|
26
|
+
klass.instance_eval {
|
|
27
|
+
attr_writer variable_name
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if $0 == __FILE__
|
|
34
|
+
require 'test/unit'
|
|
35
|
+
$test = true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if defined?($test) && $test
|
|
39
|
+
class TestModulePublicDummyClass
|
|
40
|
+
def initialize
|
|
41
|
+
@var = 't'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def hello
|
|
47
|
+
return 'hello'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class TestTestModulePublic < Test::Unit::TestCase
|
|
52
|
+
include TestModulePublic
|
|
53
|
+
|
|
54
|
+
def test_all
|
|
55
|
+
dc = TestModulePublicDummyClass.new
|
|
56
|
+
|
|
57
|
+
# test_t_make_public
|
|
58
|
+
assert_equal true, dc.private_methods.include?('hello')
|
|
59
|
+
assert_equal false, dc.public_methods.include?('hello')
|
|
60
|
+
t_make_public(TestModulePublicDummyClass, :hello)
|
|
61
|
+
assert_equal 'hello', dc.hello
|
|
62
|
+
assert_equal false, dc.private_methods.include?('hello')
|
|
63
|
+
assert_equal true, dc.public_methods.include?('hello')
|
|
64
|
+
|
|
65
|
+
# test_t_make_readable
|
|
66
|
+
t_make_readable(TestModulePublicDummyClass, :var)
|
|
67
|
+
assert_equal 't', dc.var
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
|
|
7
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
8
|
+
require 'qwik/testunit'
|
|
9
|
+
require 'qwik/config'
|
|
10
|
+
require 'qwik/htree-to-wabisabi'
|
|
11
|
+
require 'qwik/test-module-path'
|
|
12
|
+
|
|
13
|
+
module TestServerSetupModule
|
|
14
|
+
def setup
|
|
15
|
+
@dir = '.test/data/test'.path
|
|
16
|
+
@dir.setup
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def teardown
|
|
20
|
+
@dir.teardown
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module TestServerModule
|
|
25
|
+
def setup_server(bind_address = '127.0.0.1')
|
|
26
|
+
config = Qwik::Config.new
|
|
27
|
+
config.update Qwik::Config::DebugConfig
|
|
28
|
+
config.update Qwik::Config::TestConfig
|
|
29
|
+
config[:bind_address] = bind_address
|
|
30
|
+
|
|
31
|
+
server = Qwik::Server.new(config)
|
|
32
|
+
|
|
33
|
+
memory = server.memory
|
|
34
|
+
|
|
35
|
+
wreq = Qwik::WEBrickRequest.new(server.config)
|
|
36
|
+
wreq.request_uri = URI.parse('http://example.com/test/')
|
|
37
|
+
wreq.peeraddr = [nil, nil, nil, '127.0.0.1']
|
|
38
|
+
|
|
39
|
+
wres = Qwik::WEBrickResponse.new(server.config)
|
|
40
|
+
wres.set_config
|
|
41
|
+
|
|
42
|
+
return server, config, memory, wreq, wres
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def session(config, memory, wreq, wres)
|
|
46
|
+
req = Qwik::Request.new(config)
|
|
47
|
+
req.parse_webrick(wreq)
|
|
48
|
+
|
|
49
|
+
res = Qwik::Response.new(config)
|
|
50
|
+
res.set_webrick(wres)
|
|
51
|
+
|
|
52
|
+
action = Qwik::Action.new
|
|
53
|
+
action.init(config, memory, req, res)
|
|
54
|
+
action.run
|
|
55
|
+
|
|
56
|
+
res.setback(wres)
|
|
57
|
+
|
|
58
|
+
return wres
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def teardown_server(server)
|
|
62
|
+
server.shutdown
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def write_page(pagekey, content)
|
|
66
|
+
file = @dir+"#{pagekey}.txt"
|
|
67
|
+
file.put(content+"\n")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def read_page(pagekey)
|
|
71
|
+
file = @dir+"#{pagekey}.txt"
|
|
72
|
+
str = file.read
|
|
73
|
+
return str
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def get_uri(uri)
|
|
77
|
+
hash = {
|
|
78
|
+
'Cookie' => "userpass=user@e.com,95988593; path=/;",
|
|
79
|
+
}
|
|
80
|
+
str = ''
|
|
81
|
+
open(uri, hash) {|f|
|
|
82
|
+
str = f.read
|
|
83
|
+
}
|
|
84
|
+
return str
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def get_path(path)
|
|
88
|
+
return get_uri("http://127.0.0.1:9190/test/#{path}")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def ok_xp(e, path, str)
|
|
92
|
+
ok_eq(e, HTree(str).to_wabisabi.get_path(path))
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def ok_in(e, path, str)
|
|
96
|
+
ok_eq(e, HTree(str).to_wabisabi.get_path(path).inside.get_single)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Copyright (C) 2003-2006 Kouichirou Eto, All rights reserved.
|
|
2
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
|
3
|
+
# You can redistribute it and/or modify it under the terms of the GNU GPL 2.
|
|
4
|
+
|
|
5
|
+
require 'webrick/log'
|
|
6
|
+
|
|
7
|
+
$LOAD_PATH.unshift '..' unless $LOAD_PATH.include? '..'
|
|
8
|
+
require 'qwik/testunit'
|
|
9
|
+
require 'qwik/test-module-path'
|
|
10
|
+
require 'qwik/test-module-public'
|
|
11
|
+
require 'qwik/request'
|
|
12
|
+
require 'qwik/response'
|
|
13
|
+
require 'qwik/loadlib'
|
|
14
|
+
require 'qwik/qp'
|
|
15
|
+
require 'logger'
|
|
16
|
+
|
|
17
|
+
module TestSession
|
|
18
|
+
include TestModulePublic
|
|
19
|
+
|
|
20
|
+
DEFAULT_USER = 'user@e.com'
|
|
21
|
+
|
|
22
|
+
TEST_PNG_DATA = "\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000\001\000\000\000\001\010\002\000\000\000\220wS\336\000\000\000\fIDATx\332c\370\377\377?\000\005\376\002\3763\022\225\024\000\000\000\000IEND\256B`\202"
|
|
23
|
+
|
|
24
|
+
# ============================== setup
|
|
25
|
+
def setup
|
|
26
|
+
web_setup
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def web_setup
|
|
30
|
+
# setup config
|
|
31
|
+
if ! defined?($test_config)
|
|
32
|
+
config = Qwik::Config.new
|
|
33
|
+
$test_org_sites_dir = config[:sites_dir].dup
|
|
34
|
+
config.update(Qwik::Config::DebugConfig)
|
|
35
|
+
config.update(Qwik::Config::TestConfig)
|
|
36
|
+
$test_config = config
|
|
37
|
+
end
|
|
38
|
+
@config = $test_config
|
|
39
|
+
@org_sites_dir = $test_org_sites_dir
|
|
40
|
+
|
|
41
|
+
@config.sites_dir.path.check_directory
|
|
42
|
+
@config.grave_dir.path.check_directory
|
|
43
|
+
@config.cache_dir.path.check_directory
|
|
44
|
+
@config.etc_dir.path.check_directory
|
|
45
|
+
@config.log_dir.path.check_directory
|
|
46
|
+
|
|
47
|
+
# setup memory
|
|
48
|
+
if ! defined?($test_memory)
|
|
49
|
+
memory = Qwik::ServerMemory.new(@config)
|
|
50
|
+
logfile = '.test/testlog.txt'
|
|
51
|
+
loglevel = WEBrick::Log::INFO
|
|
52
|
+
logger = WEBrick::Log::new(logfile, loglevel)
|
|
53
|
+
memory[:logger] = logger
|
|
54
|
+
|
|
55
|
+
burylogfile = '.test/testburylog.txt'
|
|
56
|
+
log = ::Logger.new(burylogfile)
|
|
57
|
+
log.level = ::Logger::INFO
|
|
58
|
+
memory[:bury_log] = log
|
|
59
|
+
|
|
60
|
+
$test_memory = memory
|
|
61
|
+
end
|
|
62
|
+
@memory = $test_memory
|
|
63
|
+
|
|
64
|
+
# setup dir
|
|
65
|
+
@wwwdir = @config.sites_dir.path + 'www'
|
|
66
|
+
@wwwdir.setup
|
|
67
|
+
@dir = @config.sites_dir.path + 'test'
|
|
68
|
+
@dir.setup
|
|
69
|
+
|
|
70
|
+
# setup site
|
|
71
|
+
@site = @memory.farm.get_site('test')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# ============================== teardown
|
|
75
|
+
def teardown
|
|
76
|
+
web_teardown
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def web_teardown
|
|
80
|
+
@site.erase_all if defined?(@site) && @site
|
|
81
|
+
@wwwdir.teardown if @wwwdir
|
|
82
|
+
#assert_equal false, (@dir+"test").exist?
|
|
83
|
+
@dir.teardown if @dir
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# ============================== session
|
|
87
|
+
def session(path = '/test/')
|
|
88
|
+
# setup_req
|
|
89
|
+
req = Qwik::Request.new(@config)
|
|
90
|
+
|
|
91
|
+
# setup user
|
|
92
|
+
t_setup_user(@memory, req, DEFAULT_USER)
|
|
93
|
+
|
|
94
|
+
# parse_host
|
|
95
|
+
req.instance_eval {
|
|
96
|
+
@fromhost = 'example.com'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if /\APOST / =~ path
|
|
100
|
+
req.instance_eval {
|
|
101
|
+
@request_method = 'POST'
|
|
102
|
+
}
|
|
103
|
+
path.sub!(/\APOST /, "")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if path.include?("?")
|
|
107
|
+
path, query_str = path.split("?", 2)
|
|
108
|
+
query = WEBrick::HTTPUtils.parse_query(query_str)
|
|
109
|
+
req.query.clear
|
|
110
|
+
req.query.update(query)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
req.parse_path(path)
|
|
114
|
+
req.accept_language = ['en']
|
|
115
|
+
req.instance_eval {
|
|
116
|
+
@fromhost = 'localhost'
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# setup_res
|
|
120
|
+
res = Qwik::Response.new(@config)
|
|
121
|
+
res.make_mimetypes(WEBrick::HTTPUtils::DefaultMimeTypes)
|
|
122
|
+
|
|
123
|
+
# setup_action
|
|
124
|
+
@action = Qwik::Action.new
|
|
125
|
+
@action.init(@config, @memory, req, res)
|
|
126
|
+
site = @site
|
|
127
|
+
@action.instance_eval {
|
|
128
|
+
@site = site;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Setup request by block.
|
|
132
|
+
yield(req) if block_given?
|
|
133
|
+
|
|
134
|
+
action = Qwik::Action.new
|
|
135
|
+
action.init(@config, @memory, req, res)
|
|
136
|
+
action.run
|
|
137
|
+
|
|
138
|
+
dummy_str = res.setback_body(res.body)
|
|
139
|
+
|
|
140
|
+
@res = res
|
|
141
|
+
# Since @res is not thread safe, return res instead of @res.
|
|
142
|
+
return res
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def t_setup_user(memory, req, user)
|
|
146
|
+
req.cookies['user'] = user
|
|
147
|
+
req.cookies['pass'] = memory.passgen.generate(user)
|
|
148
|
+
end
|
|
149
|
+
private :t_setup_user
|
|
150
|
+
|
|
151
|
+
# ==================== test common
|
|
152
|
+
def t_site_open
|
|
153
|
+
page = @site['_SiteConfig']
|
|
154
|
+
page.put_with_time(':open:true', 0)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def t_add_user(user = DEFAULT_USER)
|
|
158
|
+
@site.member.add(user) unless @site.member.exist?(user)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def t_without_testmode
|
|
162
|
+
org_test = @config.test
|
|
163
|
+
org_debug = @config.debug
|
|
164
|
+
@config[:test] = false
|
|
165
|
+
@config[:debug] = false
|
|
166
|
+
yield
|
|
167
|
+
@config[:test] = org_test
|
|
168
|
+
@config[:debug] = org_debug
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def t_with_site(sitename)
|
|
172
|
+
dir = ("#{sitename}/").path
|
|
173
|
+
dir.setup
|
|
174
|
+
yield
|
|
175
|
+
dir.teardown
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def t_make_content(filename, data)
|
|
179
|
+
content = WEBrick::HTTPUtils::FormData.new(data)
|
|
180
|
+
content.filename = filename
|
|
181
|
+
return content
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def t_with_path
|
|
185
|
+
org_public_url = @config[:public_url]
|
|
186
|
+
@config[:public_url] = "http://www.example.org/qwik/"
|
|
187
|
+
yield
|
|
188
|
+
@config[:public_url] = org_public_url
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def t_with_siteurl(url='http://example.org/q/')
|
|
192
|
+
siteconfig = @site['_SiteConfig']
|
|
193
|
+
siteconfig.store ":siteurl:#{url}\n"
|
|
194
|
+
yield
|
|
195
|
+
siteconfig.store ""
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# ==================== assert xpath module
|
|
199
|
+
def assert_path(e, w, user=DEFAULT_USER, path="//div[@class='section']", &b)
|
|
200
|
+
t_add_user if user
|
|
201
|
+
|
|
202
|
+
page = @site['1']
|
|
203
|
+
page = @site.create('1') if page.nil?
|
|
204
|
+
page.store(w)
|
|
205
|
+
res = session('/test/1.html') {|req|
|
|
206
|
+
yield(req) if block_given?
|
|
207
|
+
t_setup_user(@memory, req, user)
|
|
208
|
+
}
|
|
209
|
+
div = res.body.get_path(path)
|
|
210
|
+
|
|
211
|
+
if e.is_a? Array
|
|
212
|
+
return assert_equal(e, div.inside.remove_comment.get_single)
|
|
213
|
+
end
|
|
214
|
+
return assert_equal_or_match(e, div.inside.rb_format_xml(-1, -1).chomp)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def ok_wi(e, w, &b)
|
|
218
|
+
return assert_path(e, w, DEFAULT_USER, "//div[@class='section']", &b)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# ==================== show
|
|
222
|
+
# Get element by XPath and show it in pretty print mode.
|
|
223
|
+
def pw(xpath=nil, res=@res)
|
|
224
|
+
pp res.body.get_path(xpath)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# ==================== assert module
|
|
228
|
+
def assert_equal_or_match(e, s)
|
|
229
|
+
return assert_match(e, s) if e.is_a? Regexp
|
|
230
|
+
return assert_equal(e, s)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def ok_xp(e, path, res=@res)
|
|
234
|
+
elem = res.body.get_path(path)
|
|
235
|
+
return assert_equal(e, nil) if elem.nil?
|
|
236
|
+
return assert_equal(e, elem.remove_comment)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def ok_in(e, path, res=@res)
|
|
240
|
+
elem = res.body.get_path(path)
|
|
241
|
+
return assert_equal(e, nil) if elem.nil?
|
|
242
|
+
return assert_equal(e, elem.inside.get_single)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def ok_title(e, res=@res)
|
|
246
|
+
elem = res.body.get_path('//title')
|
|
247
|
+
return assert_equal(e, nil) if elem.nil?
|
|
248
|
+
return assert_equal(e, elem.inside.get_single[0])
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def assert_text(e, tag, res=@res)
|
|
252
|
+
elem = res.body.get_tag(tag)
|
|
253
|
+
return assert_equal(e, nil) if elem.nil?
|
|
254
|
+
return assert_equal_or_match(e, elem.text)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def ok_attr(e, s, res=@res)
|
|
258
|
+
elem = (/\A\/\// =~ s) ? res.body.get_path(s) : res.body.get_tag(s)
|
|
259
|
+
return assert_equal(e, nil) if elem.nil?
|
|
260
|
+
return assert_equal(e, elem.attr)
|
|
261
|
+
end
|
|
262
|
+
alias assert_attr ok_attr
|
|
263
|
+
alias assert_rattr ok_attr
|
|
264
|
+
end
|