ydim_html 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/LICENSE.txt +339 -0
- data/Manifest.txt +47 -0
- data/README.txt +21 -0
- data/Rakefile +28 -0
- data/bin/ydim-htmld +38 -0
- data/lib/ydim/html.rb +10 -0
- data/lib/ydim/html/config.rb +37 -0
- data/lib/ydim/html/state/ajax_values.rb +16 -0
- data/lib/ydim/html/state/autoinvoice.rb +93 -0
- data/lib/ydim/html/state/confirm.rb +15 -0
- data/lib/ydim/html/state/debitor.rb +81 -0
- data/lib/ydim/html/state/debitors.rb +23 -0
- data/lib/ydim/html/state/global.rb +99 -0
- data/lib/ydim/html/state/global_predefine.rb +13 -0
- data/lib/ydim/html/state/init.rb +20 -0
- data/lib/ydim/html/state/invoice.rb +179 -0
- data/lib/ydim/html/state/invoices.rb +69 -0
- data/lib/ydim/html/state/pdf.rb +16 -0
- data/lib/ydim/html/util/lookandfeel.rb +132 -0
- data/lib/ydim/html/util/server.rb +36 -0
- data/lib/ydim/html/util/session.rb +27 -0
- data/lib/ydim/html/util/validator.rb +62 -0
- data/lib/ydim/html/view/ajax_values.rb +22 -0
- data/lib/ydim/html/view/autoinvoice.rb +79 -0
- data/lib/ydim/html/view/autoinvoices.rb +41 -0
- data/lib/ydim/html/view/confirm.rb +27 -0
- data/lib/ydim/html/view/debitor.rb +111 -0
- data/lib/ydim/html/view/debitors.rb +44 -0
- data/lib/ydim/html/view/htmlgrid.rb +103 -0
- data/lib/ydim/html/view/init.rb +29 -0
- data/lib/ydim/html/view/invoice.rb +217 -0
- data/lib/ydim/html/view/invoices.rb +158 -0
- data/lib/ydim/html/view/navigation.rb +28 -0
- data/lib/ydim/html/view/pdf.rb +23 -0
- data/lib/ydim/html/view/template.rb +70 -0
- data/test/selenium.rb +1687 -0
- data/test/selenium/selenium-server.jar +0 -0
- data/test/selenium/test_autoinvoice.rb +318 -0
- data/test/selenium/test_debitor.rb +343 -0
- data/test/selenium/test_debitors.rb +46 -0
- data/test/selenium/test_init.rb +104 -0
- data/test/selenium/test_invoice.rb +295 -0
- data/test/selenium/test_invoices.rb +175 -0
- data/test/selenium/unit.rb +124 -0
- data/test/stub/http_server.rb +139 -0
- data/test/suite.rb +14 -0
- metadata +138 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Selenium::TestCase -- ydim -- 14.12.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
if(pid = Kernel.fork)
|
7
|
+
at_exit {
|
8
|
+
Process.kill('HUP', pid)
|
9
|
+
$selenium.stop if($selenium.respond_to?(:stop))
|
10
|
+
}
|
11
|
+
else
|
12
|
+
path = File.expand_path('selenium-server.jar', File.dirname(__FILE__))
|
13
|
+
command = "java -jar #{path} &> /dev/null"
|
14
|
+
exec(command)
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'delegate'
|
18
|
+
require 'selenium'
|
19
|
+
require 'ydim/html/config'
|
20
|
+
|
21
|
+
module YDIM
|
22
|
+
module Html
|
23
|
+
module Selenium
|
24
|
+
class SeleniumWrapper < SimpleDelegator
|
25
|
+
def initialize(host, port, browser, server, port2)
|
26
|
+
@server = server
|
27
|
+
@selenium = ::Selenium::SeleneseInterpreter.new(host, port, browser,
|
28
|
+
server, port2)
|
29
|
+
super @selenium
|
30
|
+
end
|
31
|
+
def open(path)
|
32
|
+
@selenium.open(@server + path)
|
33
|
+
end
|
34
|
+
def type(*args)
|
35
|
+
@selenium.type(*args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
$selenium = YDIM::Html::Selenium::SeleniumWrapper.new("localhost",
|
43
|
+
4444, "*chrome",
|
44
|
+
YDIM::Html.config.http_server + ":10080", 10000)
|
45
|
+
|
46
|
+
start = Time.now
|
47
|
+
begin
|
48
|
+
$selenium.start
|
49
|
+
rescue Errno::ECONNREFUSED
|
50
|
+
print "."
|
51
|
+
sleep 1
|
52
|
+
if((Time.now - start) > 15)
|
53
|
+
raise
|
54
|
+
else
|
55
|
+
retry
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
require "ydim/html/util/server"
|
60
|
+
require 'flexmock'
|
61
|
+
require 'logger'
|
62
|
+
require 'stub/http_server'
|
63
|
+
require "test/unit"
|
64
|
+
|
65
|
+
module YDIM
|
66
|
+
module Html
|
67
|
+
module Selenium
|
68
|
+
module TestCase
|
69
|
+
include FlexMock::TestCase
|
70
|
+
include SeleniumHelper
|
71
|
+
def setup
|
72
|
+
Html.config.email = 'test@ywesee.com'
|
73
|
+
Html.config.md5_pass = Digest::MD5.hexdigest('secret')
|
74
|
+
Html.logger = Logger.new($stdout)
|
75
|
+
Html.logger.level = Logger::DEBUG
|
76
|
+
@ydim_server = flexmock("ydim_server")
|
77
|
+
@server = Html::Util::Server.new(@ydim_server)
|
78
|
+
@server.extend(DRbUndumped)
|
79
|
+
drb_url = "druby://localhost:10081"
|
80
|
+
@drb = Thread.new {
|
81
|
+
@drb_server = DRb.start_service(drb_url, @server)
|
82
|
+
}
|
83
|
+
@drb.abort_on_exception = true
|
84
|
+
@http_server = Stub.http_server(drb_url)
|
85
|
+
@webrick = Thread.new { @http_server.start }
|
86
|
+
@verification_errors = []
|
87
|
+
if $selenium
|
88
|
+
@selenium = $selenium
|
89
|
+
else
|
90
|
+
@selenium = SeleniumWrapper.new("localhost", 4444, "*chrome",
|
91
|
+
Html.config.http_server + ":10080", 10000)
|
92
|
+
@selenium.start
|
93
|
+
end
|
94
|
+
@selenium.set_context("TestOddb")
|
95
|
+
end
|
96
|
+
def teardown
|
97
|
+
@selenium.stop unless $selenium
|
98
|
+
@http_server.shutdown
|
99
|
+
@drb_server.stop_service
|
100
|
+
assert_equal [], @verification_errors
|
101
|
+
super
|
102
|
+
end
|
103
|
+
def login(debitors=[])
|
104
|
+
session = flexmock('session')
|
105
|
+
@ydim_server.should_receive(:login).and_return(session)
|
106
|
+
session.should_receive(:debitors).and_return(debitors)
|
107
|
+
@ydim_server.should_receive(:logout)
|
108
|
+
@selenium.open "/"
|
109
|
+
assert_equal "YDIM", @selenium.get_title
|
110
|
+
@selenium.type "email", "test@ywesee.com"
|
111
|
+
@selenium.type "pass", "secret"
|
112
|
+
@selenium.click "login"
|
113
|
+
@selenium.wait_for_page_to_load "30000"
|
114
|
+
converter = flexmock('session')
|
115
|
+
converter.should_receive(:convert).and_return { |amount, from, to|
|
116
|
+
amount
|
117
|
+
}
|
118
|
+
session.should_receive(:currency_converter).and_return(converter)
|
119
|
+
session
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Stub.http_server -- de.oddb.org -- 21.11.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
require 'sbsm/request'
|
5
|
+
require 'sbsm/trans_handler'
|
6
|
+
require 'webrick'
|
7
|
+
|
8
|
+
class Object
|
9
|
+
def meta_class; class << self; self; end; end
|
10
|
+
def meta_eval &blk; meta_class.instance_eval &blk; end
|
11
|
+
end
|
12
|
+
|
13
|
+
## compatibility-brainfuck for integrating Apache-SBSM-Requests with WEBrick
|
14
|
+
module YDIM
|
15
|
+
module Html
|
16
|
+
YDIM_VERSION = "test-version"
|
17
|
+
module Stub
|
18
|
+
class Notes < Hash
|
19
|
+
alias :add :store
|
20
|
+
end
|
21
|
+
class Output < String
|
22
|
+
alias :write :<<
|
23
|
+
alias :print :<<
|
24
|
+
end
|
25
|
+
class HTTPServer < WEBrick::HTTPServer
|
26
|
+
attr_accessor :document_root
|
27
|
+
def method_missing(method, *args, &block)
|
28
|
+
@logger.warn "ignoring method: #{method}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
def Stub.http_server(drburi, log_level=0)
|
32
|
+
doc = File.expand_path('../../doc', File.dirname(__FILE__))
|
33
|
+
logger = WEBrick::Log.new
|
34
|
+
logger.level = log_level
|
35
|
+
config = { :Host => 'localhost', :Port => 10080,
|
36
|
+
:DocumentRoot => doc, :Logger => logger }
|
37
|
+
if(log_level == 0)
|
38
|
+
config.store(:AccessLog, [])
|
39
|
+
end
|
40
|
+
server = HTTPServer.new(config)
|
41
|
+
server.document_root = doc
|
42
|
+
application = Proc.new { |req, resp|
|
43
|
+
if(req.uri == '/favicon.ico')
|
44
|
+
resp.body = File.open(File.join(doc, req.uri))
|
45
|
+
else
|
46
|
+
ARGV.push('')
|
47
|
+
req.server = server
|
48
|
+
# ignore selenium/dojo-added GET-Parameters
|
49
|
+
req.uri = CGI.unescape(req.uri[/^[^?]*/])
|
50
|
+
SBSM::TransHandler.instance.translate_uri(req)
|
51
|
+
## not Threadsafe!
|
52
|
+
SBSM::Apache.request = req
|
53
|
+
output = Output.new
|
54
|
+
sbsm = SBSM::Request.new(drburi)
|
55
|
+
sbsm.meta_eval { define_method(:handle_exception) { |e| raise e } }
|
56
|
+
sbsm.cgi.params.update(req.query)
|
57
|
+
sbsm.cgi.env_table['SERVER_NAME'] =
|
58
|
+
YDIM::Html.config.http_server.gsub('http://', '') + ':10080'
|
59
|
+
sbsm.cgi.env_table['REQUEST_METHOD'] = req.request_method
|
60
|
+
sbsm.cgi.cookies['_session_id'] = 'test:preset-session-id'
|
61
|
+
sbsm.cgi.output = output
|
62
|
+
sbsm.process
|
63
|
+
if(/^location:/i.match(output))
|
64
|
+
resp.status = 303
|
65
|
+
end
|
66
|
+
resp.rawdata = true
|
67
|
+
resp.body = output
|
68
|
+
end
|
69
|
+
}
|
70
|
+
server.mount_proc('/', &application)
|
71
|
+
server.mount_proc('/de', &application)
|
72
|
+
server.mount_proc('/de/.*', &application)
|
73
|
+
res = File.join(doc, 'resources')
|
74
|
+
server.mount('/resources', WEBrick::HTTPServlet::FileHandler, res, {})
|
75
|
+
server
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
module WEBrick
|
81
|
+
class HTTPRequest
|
82
|
+
attr_accessor :server, :uri, :notes
|
83
|
+
alias :__old_initialize__ :initialize
|
84
|
+
def initialize(*args)
|
85
|
+
__old_initialize__(*args)
|
86
|
+
@notes = YDIM::Html::Stub::Notes.new
|
87
|
+
end
|
88
|
+
def headers_in
|
89
|
+
headers = {}
|
90
|
+
if(@header)
|
91
|
+
@header.each { |key, vals| headers.store(key, vals.join(';')) }
|
92
|
+
end
|
93
|
+
headers
|
94
|
+
end
|
95
|
+
def uri
|
96
|
+
@uri || unparsed_uri
|
97
|
+
end
|
98
|
+
end
|
99
|
+
class HTTPResponse
|
100
|
+
attr_accessor :rawdata
|
101
|
+
alias :__old_send_header__ :send_header
|
102
|
+
def send_header(socket)
|
103
|
+
if(@rawdata)
|
104
|
+
_write_data(socket, status_line)
|
105
|
+
else
|
106
|
+
__old_send_header__(socket)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
alias :__old_setup_header__ :setup_header
|
110
|
+
def setup_header()
|
111
|
+
unless(@rawdata)
|
112
|
+
__old_setup_header__
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
module SBSM
|
118
|
+
class Request
|
119
|
+
def handle_exception(e)
|
120
|
+
raise e
|
121
|
+
end
|
122
|
+
end
|
123
|
+
module Apache
|
124
|
+
DECLINED = nil
|
125
|
+
def Apache.request=(request)
|
126
|
+
@request = request
|
127
|
+
end
|
128
|
+
def Apache.request
|
129
|
+
@request
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
class CGI
|
134
|
+
attr_accessor :output
|
135
|
+
def stdoutput
|
136
|
+
output
|
137
|
+
end
|
138
|
+
public :env_table
|
139
|
+
end
|
data/test/suite.rb
ADDED
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ydim_html
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-20 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: hoe
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 47
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 8
|
33
|
+
- 0
|
34
|
+
version: 2.8.0
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: ywesee Distributed Invoice Manager HTML Interface, Ruby
|
38
|
+
email:
|
39
|
+
- mhatakeyama@ywesee.com, zdavatz@ywesee.com
|
40
|
+
executables:
|
41
|
+
- ydim-htmld
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files:
|
45
|
+
- History.txt
|
46
|
+
- LICENSE.txt
|
47
|
+
- Manifest.txt
|
48
|
+
- README.txt
|
49
|
+
files:
|
50
|
+
- History.txt
|
51
|
+
- LICENSE.txt
|
52
|
+
- Manifest.txt
|
53
|
+
- README.txt
|
54
|
+
- Rakefile
|
55
|
+
- bin/ydim-htmld
|
56
|
+
- lib/ydim/html.rb
|
57
|
+
- lib/ydim/html/config.rb
|
58
|
+
- lib/ydim/html/state/ajax_values.rb
|
59
|
+
- lib/ydim/html/state/autoinvoice.rb
|
60
|
+
- lib/ydim/html/state/confirm.rb
|
61
|
+
- lib/ydim/html/state/debitor.rb
|
62
|
+
- lib/ydim/html/state/debitors.rb
|
63
|
+
- lib/ydim/html/state/global.rb
|
64
|
+
- lib/ydim/html/state/global_predefine.rb
|
65
|
+
- lib/ydim/html/state/init.rb
|
66
|
+
- lib/ydim/html/state/invoice.rb
|
67
|
+
- lib/ydim/html/state/invoices.rb
|
68
|
+
- lib/ydim/html/state/pdf.rb
|
69
|
+
- lib/ydim/html/util/lookandfeel.rb
|
70
|
+
- lib/ydim/html/util/server.rb
|
71
|
+
- lib/ydim/html/util/session.rb
|
72
|
+
- lib/ydim/html/util/validator.rb
|
73
|
+
- lib/ydim/html/view/ajax_values.rb
|
74
|
+
- lib/ydim/html/view/autoinvoice.rb
|
75
|
+
- lib/ydim/html/view/autoinvoices.rb
|
76
|
+
- lib/ydim/html/view/confirm.rb
|
77
|
+
- lib/ydim/html/view/debitor.rb
|
78
|
+
- lib/ydim/html/view/debitors.rb
|
79
|
+
- lib/ydim/html/view/htmlgrid.rb
|
80
|
+
- lib/ydim/html/view/init.rb
|
81
|
+
- lib/ydim/html/view/invoice.rb
|
82
|
+
- lib/ydim/html/view/invoices.rb
|
83
|
+
- lib/ydim/html/view/navigation.rb
|
84
|
+
- lib/ydim/html/view/pdf.rb
|
85
|
+
- lib/ydim/html/view/template.rb
|
86
|
+
- test/selenium.rb
|
87
|
+
- test/selenium/selenium-server.jar
|
88
|
+
- test/selenium/test_autoinvoice.rb
|
89
|
+
- test/selenium/test_debitor.rb
|
90
|
+
- test/selenium/test_debitors.rb
|
91
|
+
- test/selenium/test_init.rb
|
92
|
+
- test/selenium/test_invoice.rb
|
93
|
+
- test/selenium/test_invoices.rb
|
94
|
+
- test/selenium/unit.rb
|
95
|
+
- test/stub/http_server.rb
|
96
|
+
- test/suite.rb
|
97
|
+
has_rdoc: true
|
98
|
+
homepage: http://scm.ywesee.com/?p=ydim-html/.git;a=summary
|
99
|
+
licenses: []
|
100
|
+
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- --main
|
104
|
+
- README.txt
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
requirements: []
|
126
|
+
|
127
|
+
rubyforge_project: ydim_html
|
128
|
+
rubygems_version: 1.3.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: ywesee Distributed Invoice Manager HTML Interface, Ruby
|
132
|
+
test_files:
|
133
|
+
- test/selenium/test_autoinvoice.rb
|
134
|
+
- test/selenium/test_debitor.rb
|
135
|
+
- test/selenium/test_debitors.rb
|
136
|
+
- test/selenium/test_init.rb
|
137
|
+
- test/selenium/test_invoice.rb
|
138
|
+
- test/selenium/test_invoices.rb
|