nitro 0.21.2 → 0.22.0
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/CHANGELOG +121 -0
- data/README +9 -3
- data/doc/RELEASES +86 -1
- data/lib/nitro.rb +1 -1
- data/lib/nitro/adapter/cgi.rb +4 -1
- data/lib/nitro/adapter/scgi.rb +2 -0
- data/lib/nitro/adapter/webrick.rb +1 -1
- data/lib/nitro/caching/output.rb +6 -5
- data/lib/nitro/compiler.rb +8 -3
- data/lib/nitro/dispatcher.rb +2 -2
- data/lib/nitro/dispatcher/nice.rb +1 -1
- data/lib/nitro/element.rb +19 -2
- data/lib/nitro/mixin/markup.rb +2 -2
- data/lib/nitro/mixin/pager.rb +80 -25
- data/lib/nitro/mixin/rss.rb +5 -2
- data/lib/nitro/render.rb +9 -0
- data/lib/nitro/request.rb +93 -6
- data/lib/nitro/response.rb +4 -0
- data/lib/nitro/server.rb +24 -10
- data/lib/nitro/server/runner.rb +15 -10
- data/lib/nitro/service/xmlrpc.rb +1 -0
- data/lib/nitro/test.rb +5 -0
- data/lib/nitro/test/assertions.rb +171 -0
- data/lib/nitro/{testing → test}/context.rb +0 -0
- data/lib/nitro/test/testcase.rb +66 -0
- data/proto/public/error.xhtml +5 -2
- data/proto/public/settings.xhtml +2 -0
- data/proto/script/runner +20 -0
- data/test/nitro/tc_controller.rb +3 -3
- data/test/nitro/tc_controller_aspect.rb +29 -0
- data/test/nitro/tc_dispatcher.rb +2 -1
- data/test/nitro/tc_element.rb +9 -0
- data/test/nitro/tc_request.rb +38 -0
- metadata +13 -13
- data/lib/nitro/mail.rb +0 -270
- data/lib/nitro/template.rb +0 -202
- data/lib/nitro/testing.rb +0 -2
- data/lib/nitro/testing/assertions.rb +0 -100
- data/lib/nitro/testing/testcase.rb +0 -51
- data/test/nitro/tc_mail.rb +0 -97
- data/test/nitro/tc_template.rb +0 -32
data/lib/nitro/testing.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'test/unit/assertions'
|
3
|
-
require 'rexml/document'
|
4
|
-
|
5
|
-
module Test::Unit::Assertions
|
6
|
-
|
7
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
8
|
-
# :section: General assertions.
|
9
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
10
|
-
|
11
|
-
def assert_status_ok(msg = nil)
|
12
|
-
msg = format_msg("Status not ok", msg)
|
13
|
-
assert_block(msg) { @context.status_ok? }
|
14
|
-
end
|
15
|
-
|
16
|
-
def assert_output_match(re, msg = nil)
|
17
|
-
msg = format_msg("Rendered output does not match '#{re}'", msg)
|
18
|
-
assert_block(msg) { @context.out =~ Regexp.new(re) }
|
19
|
-
end
|
20
|
-
alias_method :assert_output_contains, :assert_output_match
|
21
|
-
|
22
|
-
def assert_output_no_match(re, msg = nil)
|
23
|
-
msg = format_msg("Rendered output matches '#{re}'", msg)
|
24
|
-
assert_block(msg) { @context.out =~ Regexp.new(re) }
|
25
|
-
end
|
26
|
-
alias_method :assert_output_contains_no, :assert_output_no_match
|
27
|
-
|
28
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
29
|
-
# :section: Session related assertions.
|
30
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
31
|
-
|
32
|
-
def assert_session_has(key, msg = nil)
|
33
|
-
msg = format_msg("Object '#{key}' not found in session", msg)
|
34
|
-
assert_block(msg) { @context.session[key] }
|
35
|
-
end
|
36
|
-
|
37
|
-
def assert_session_has_no(key, msg = nil)
|
38
|
-
msg = format_msg("Unexpected object '#{key}' found in session", msg)
|
39
|
-
assert_block(msg) { !@context.session[key] }
|
40
|
-
end
|
41
|
-
alias_method :assert_session_has_not, :assert_session_has_no
|
42
|
-
|
43
|
-
def assert_session_equal(key, value, msg = nil)
|
44
|
-
msg = format_msg("The value of session object '#{key}' is '#{@context.session[key]}' but was expected '#{value}'", msg)
|
45
|
-
assert_block(msg) { @context.session[key] == value }
|
46
|
-
end
|
47
|
-
|
48
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
49
|
-
# :section: Cookies related assertions.
|
50
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
51
|
-
|
52
|
-
def assert_has_cookie(name, msg = nil)
|
53
|
-
msg = format_msg("Cookie '#{name}' not found", msg)
|
54
|
-
assert_block(msg) { @context.response_cookie(name) }
|
55
|
-
end
|
56
|
-
|
57
|
-
def assert_has_no_cookie(name, msg = nil)
|
58
|
-
msg = format_msg("Unexpected cookie '#{name}' found", msg)
|
59
|
-
assert_block(msg) { !@context.response_cookie(name) }
|
60
|
-
end
|
61
|
-
|
62
|
-
def assert_cookie_equal(name, value, msg = nil)
|
63
|
-
unless cookie = @context.response_cookie(name)
|
64
|
-
msg = format_msg("Cookie '#{name}' not found", msg)
|
65
|
-
assert_block(msg) { false }
|
66
|
-
end
|
67
|
-
msg = format_msg("The value of cookie '#{name}' is '#{cookie.value}' but was expected '#{value}'", msg)
|
68
|
-
assert_block(msg) { cookie.value == value }
|
69
|
-
end
|
70
|
-
|
71
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
72
|
-
# :section: Template related assertions.
|
73
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
74
|
-
|
75
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
76
|
-
# :section: Redirection assertions.
|
77
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
78
|
-
|
79
|
-
def assert_redirect(msg = nil)
|
80
|
-
msg = format_msg("No redirection (status = #{@context.status})", msg)
|
81
|
-
assert_block(msg) { @context.redirect? }
|
82
|
-
end
|
83
|
-
|
84
|
-
def assert_no_redirect(msg = nil)
|
85
|
-
msg = format_msg("Unexpected redirection (location = '#{@context.response_headers['location']}')", msg)
|
86
|
-
assert_block(msg) { !@context.redirect? }
|
87
|
-
end
|
88
|
-
|
89
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
90
|
-
# :section: Utility methods
|
91
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
92
|
-
|
93
|
-
def format_msg(message, extra) # :nodoc:
|
94
|
-
extra += ', ' if extra
|
95
|
-
return "#{extra}#{message}"
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
# * George Moschovitis <gm@navel.gr>
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'test/unit/assertions'
|
3
|
-
require 'rexml/document'
|
4
|
-
|
5
|
-
require 'glue'
|
6
|
-
require 'glue/logger'
|
7
|
-
require 'nitro/conf'
|
8
|
-
require 'nitro/testing/context'
|
9
|
-
|
10
|
-
module Test::Unit
|
11
|
-
|
12
|
-
class TestCase
|
13
|
-
include Nitro
|
14
|
-
|
15
|
-
attr_accessor :conf
|
16
|
-
attr_accessor :context
|
17
|
-
|
18
|
-
def handle(path, request = {}, session = nil, headers = {})
|
19
|
-
@conf ||= Conf.new({})
|
20
|
-
@conf.public_root ||= File.join(File.dirname(__FILE__), '..', 'public')
|
21
|
-
@conf.template_root ||= File.join(File.dirname(__FILE__), '..', 'public')
|
22
|
-
|
23
|
-
begin
|
24
|
-
context = Context.new(@conf)
|
25
|
-
|
26
|
-
# context.in = StringIO.new(req.body || "")
|
27
|
-
|
28
|
-
context.params = request
|
29
|
-
context.headers ||= headers
|
30
|
-
context.session = session if session
|
31
|
-
|
32
|
-
context.headers['REQUEST_URI'] = path
|
33
|
-
# CgiUtils.parse_params(context)
|
34
|
-
# CgiUtils.parse_cookies(context)
|
35
|
-
|
36
|
-
context.render(path)
|
37
|
-
|
38
|
-
@context = context
|
39
|
-
|
40
|
-
return context
|
41
|
-
ensure
|
42
|
-
Og.manager.put_store if defined?(Og) and Og.manager
|
43
|
-
end
|
44
|
-
end
|
45
|
-
alias_method :process, :handle
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
# * George Moschovitis <gm@navel.gr>
|
data/test/nitro/tc_mail.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
$NITRO_NO_ENVIRONMENT = true
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
require 'ostruct'
|
7
|
-
|
8
|
-
require 'nitro'
|
9
|
-
require 'nitro/mail'
|
10
|
-
|
11
|
-
class TestCaseMail < Test::Unit::TestCase # :nodoc: all
|
12
|
-
include Nitro
|
13
|
-
|
14
|
-
class DummyMailer < Mailer
|
15
|
-
def initialize
|
16
|
-
super
|
17
|
-
@bcc = 'gm@navel.gr'
|
18
|
-
@template_root = 'test/public/dummy_mailer'
|
19
|
-
end
|
20
|
-
|
21
|
-
def registration(to, username, token)
|
22
|
-
@to = to
|
23
|
-
@from = 'system@navel.gr'
|
24
|
-
@subject = 'Nitro.com registration'
|
25
|
-
@cc = 'gm@navel.gr'
|
26
|
-
@body.username = username
|
27
|
-
@body.token = token
|
28
|
-
end
|
29
|
-
|
30
|
-
def greek(to)
|
31
|
-
@to = to
|
32
|
-
@from = 'system@navel.gr'
|
33
|
-
@subject = 'Ελληνικός Τίτλος'
|
34
|
-
@cc = 'gm@navel.gr'
|
35
|
-
@body = 'Τί έγινε ρε παιδιά;'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class DummyController < Controller
|
40
|
-
# mailer DummyMailer
|
41
|
-
|
42
|
-
def register
|
43
|
-
token = 999
|
44
|
-
deliver_registration('gmosx@navel.gr', 'gmosx', token)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_mail
|
49
|
-
m = Mail.new 'gmosx@navel.gr', 'drak@navel.gr', 'A simple test', 'This is the body of the message'
|
50
|
-
expected = %{From: gmosx@navel.gr
|
51
|
-
To: drak@navel.gr
|
52
|
-
Subject: A simple test
|
53
|
-
|
54
|
-
This is the body of the message}
|
55
|
-
assert_equal expected, m.encoded
|
56
|
-
|
57
|
-
m.to = %w{ renos@navel.gr stella@navel.gr }
|
58
|
-
expected = %{From: gmosx@navel.gr
|
59
|
-
To: renos@navel.gr, stella@navel.gr
|
60
|
-
Subject: A simple test
|
61
|
-
|
62
|
-
This is the body of the message}
|
63
|
-
assert_equal expected, m.encoded
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_mailer
|
68
|
-
assert_equal 0, DummyMailer.deliveries.size
|
69
|
-
|
70
|
-
Mailer.server[:address] = 'mail.navel.gr'
|
71
|
-
assert_equal 'mail.navel.gr', DummyMailer.server[:address]
|
72
|
-
|
73
|
-
DummyMailer.delivery_method = :test
|
74
|
-
DummyMailer.template_root = File.join(File.dirname(__FILE__), '..', 'root', 'dummy_mailer')
|
75
|
-
token = 999
|
76
|
-
DummyMailer.deliver_registration('gm@navel.gr', 'gmosx', token)
|
77
|
-
assert_equal 1, DummyMailer.deliveries.size
|
78
|
-
|
79
|
-
expected = %{From: system@navel.gr
|
80
|
-
To: gm@navel.gr
|
81
|
-
Cc: gm@navel.gr
|
82
|
-
Bcc: gm@navel.gr
|
83
|
-
Subject: =?utf-8?Q?Nitro=2ecom_registration?=
|
84
|
-
|
85
|
-
Hello gmosx
|
86
|
-
|
87
|
-
how do you feel?
|
88
|
-
|
89
|
-
Here is your <b>Token</b>: 999
|
90
|
-
}
|
91
|
-
assert_equal expected, DummyMailer.deliveries[0].encoded
|
92
|
-
|
93
|
-
DummyMailer.deliver_greek('gm@navel.gr')
|
94
|
-
assert_equal 2, DummyMailer.deliveries.size
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
data/test/nitro/tc_template.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
require 'nitro/template'
|
7
|
-
|
8
|
-
class TC_Template < Test::Unit::TestCase # :nodoc: all
|
9
|
-
include Nitro
|
10
|
-
|
11
|
-
def test_all
|
12
|
-
template = %q{
|
13
|
-
Hello #{user}
|
14
|
-
|
15
|
-
dont forget the following todo items:
|
16
|
-
|
17
|
-
<?r for item in items ?>
|
18
|
-
<li>#{item}</li>
|
19
|
-
<?r end ?>
|
20
|
-
}
|
21
|
-
|
22
|
-
user = 'gmosx'
|
23
|
-
items = %w{ nitro is really great }
|
24
|
-
out = ''
|
25
|
-
|
26
|
-
Template.process(template, :out, binding)
|
27
|
-
|
28
|
-
assert_match %r{\<li\>nitro\</li\>}, out
|
29
|
-
assert_match %r{\<li\>really\</li\>}, out
|
30
|
-
assert_match %r{Hello gmosx}, out
|
31
|
-
end
|
32
|
-
end
|