lapillus 0.0.2
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/examples/guest_book.rb +50 -0
- data/examples/hello_world.rb +12 -0
- data/examples/persons.rb +30 -0
- data/examples/tc_guest_book.rb +34 -0
- data/examples/tc_hello_world.rb +24 -0
- data/examples/tc_persons.rb +13 -0
- data/html/GuestBook.html +24 -0
- data/html/HelloWorld.html +5 -0
- data/html/LapillusTesterTestPage.html +12 -0
- data/html/Persons.html +7 -0
- data/html/TestPage.html +8 -0
- data/html/TestRemotePanel.html +8 -0
- data/lib/changelog.txt +6 -0
- data/lib/lapillus/base.rb +276 -0
- data/lib/lapillus/behaviours.rb +208 -0
- data/lib/lapillus/components.rb +116 -0
- data/lib/lapillus/containers.rb +234 -0
- data/lib/lapillus/dispatcher.rb +216 -0
- data/lib/lapillus/form_components.rb +88 -0
- data/lib/lapillus/lapillus_server.rb +21 -0
- data/lib/lapillus/lapillus_testers.rb +167 -0
- data/lib/lapillus/mongrel_server.rb +69 -0
- data/lib/lapillus/multiview.rb +45 -0
- data/lib/lapillus/pager.rb +104 -0
- data/lib/lapillus/process_upload.rb +11 -0
- data/lib/lapillus/web_application.rb +12 -0
- data/lib/lapillus/webrick_server.rb +90 -0
- data/lib/lapillus.rb +33 -0
- data/lib/license.txt +24 -0
- data/test/tc_base.rb +63 -0
- data/test/tc_behaviours.rb +106 -0
- data/test/tc_bookmarkablepagelink.rb +58 -0
- data/test/tc_components.rb +285 -0
- data/test/tc_containers.rb +173 -0
- data/test/tc_dispatcher.rb +106 -0
- data/test/tc_examples.rb +193 -0
- data/test/tc_form.rb +231 -0
- data/test/tc_fragments.rb +114 -0
- data/test/tc_hierarchy.rb +34 -0
- data/test/tc_lapillus.rb +30 -0
- data/test/tc_lapillus_testers.rb +108 -0
- data/test/tc_multiview.rb +91 -0
- data/test/tc_pager.rb +94 -0
- data/test/tc_rendering.rb +74 -0
- data/test/ts_all_test.rb +20 -0
- metadata +94 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
require 'lapillus'
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
class TC_Fragment < Test::Unit::TestCase
|
|
5
|
+
def test_fragment
|
|
6
|
+
html = <<EOF
|
|
7
|
+
<html>
|
|
8
|
+
<body>
|
|
9
|
+
<span lapillus:id="myPanel">Example input (will be removed)</span>
|
|
10
|
+
|
|
11
|
+
<lapillus:fragment lapillus:id="frag1">panel 1</lapillus:fragment>
|
|
12
|
+
<lapillus:fragment lapillus:id="frag2">panel 2</lapillus:fragment>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
15
|
+
EOF
|
|
16
|
+
# add(Fragment.new("myPanel1", "frag1");
|
|
17
|
+
expected = <<EOF
|
|
18
|
+
<html>
|
|
19
|
+
<body>
|
|
20
|
+
<span lapillus:id="myPanel">panel 1</span>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
26
|
+
EOF
|
|
27
|
+
|
|
28
|
+
page = Webpage.new
|
|
29
|
+
page.add Fragment.new("myPanel", "frag1")
|
|
30
|
+
output = page.render(html)
|
|
31
|
+
assert_equal(expected.strip, output.strip)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_fragment_with_children
|
|
35
|
+
html = <<EOF
|
|
36
|
+
<html>
|
|
37
|
+
<body>
|
|
38
|
+
<span lapillus:id="myPanel">Example input (will be removed)</span>
|
|
39
|
+
|
|
40
|
+
<lapillus:fragment lapillus:id="frag1"><b>text comes here</b></lapillus:fragment>
|
|
41
|
+
<lapillus:fragment lapillus:id="frag2">panel 2</lapillus:fragment>
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
44
|
+
EOF
|
|
45
|
+
# add(new Fragment("myPanel1", "frag1");
|
|
46
|
+
expected = <<EOF
|
|
47
|
+
<html>
|
|
48
|
+
<body>
|
|
49
|
+
<span lapillus:id="myPanel"><b>text comes here</b></span>
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
|
55
|
+
EOF
|
|
56
|
+
|
|
57
|
+
page = Webpage.new
|
|
58
|
+
page.add Fragment.new("myPanel", "frag1")
|
|
59
|
+
output = page.render(html)
|
|
60
|
+
assert_equal(expected.strip, output.strip)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class MyFragment < Fragment
|
|
64
|
+
label "label", :model => "Hello World"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_fragment_with_components_as_children
|
|
68
|
+
html = <<EOF
|
|
69
|
+
<html>
|
|
70
|
+
<body>
|
|
71
|
+
<span lapillus:id="myPanel">Example input (will be removed)</span>
|
|
72
|
+
|
|
73
|
+
<lapillus:fragment lapillus:id="frag1"><span lapillus:id="label">text comes here</span></lapillus:fragment>
|
|
74
|
+
<lapillus:fragment lapillus:id="frag2">panel 2</lapillus:fragment>
|
|
75
|
+
</body>
|
|
76
|
+
</html>
|
|
77
|
+
EOF
|
|
78
|
+
# add(new Fragment("myPanel1", "frag1");
|
|
79
|
+
expected = <<EOF
|
|
80
|
+
<html>
|
|
81
|
+
<body>
|
|
82
|
+
<span lapillus:id="myPanel"><span lapillus:id="label">Hello World</span></span>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
</body>
|
|
87
|
+
</html>
|
|
88
|
+
EOF
|
|
89
|
+
|
|
90
|
+
page = Webpage.new
|
|
91
|
+
page.add(MyFragment.new("myPanel", "frag1"))
|
|
92
|
+
output = page.render(html)
|
|
93
|
+
assert_equal(expected.strip, output.strip)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class WeirdFragment < Fragment
|
|
97
|
+
def initialize(id, frag)
|
|
98
|
+
super(id, frag)
|
|
99
|
+
add Panel.new("properties")
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_weird_fragment
|
|
104
|
+
expected='<html><span lapillus:id="toolbar_panel"> <span class="propertiespanel" lapillus:id="properties">properties</span></span></html>'
|
|
105
|
+
html = '<html><span lapillus:id="toolbar_panel">toolbar</span>'+
|
|
106
|
+
'<lapillus:fragment lapillus:id="toolbar">'+
|
|
107
|
+
' <span class="propertiespanel" lapillus:id=\'properties\'>properties</span>'+
|
|
108
|
+
'</lapillus:fragment></html>'
|
|
109
|
+
page = Webpage.new
|
|
110
|
+
page.add(WeirdFragment.new("toolbar_panel", "toolbar"))
|
|
111
|
+
output = page.render(html)
|
|
112
|
+
assert_equal(expected, output)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'lapillus'
|
|
3
|
+
|
|
4
|
+
include Lapillus
|
|
5
|
+
|
|
6
|
+
class TC_Hierarchy < Test::Unit::TestCase
|
|
7
|
+
class TestComponent < Component
|
|
8
|
+
def render_to_element(element)
|
|
9
|
+
# do nothing
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_hierarchy_matches
|
|
14
|
+
webpage = Webpage.new
|
|
15
|
+
webpage.add(TestComponent.new("component"))
|
|
16
|
+
html = "<html><div lapillus:id=\"component\"></div></html>"
|
|
17
|
+
output = webpage.render(html)
|
|
18
|
+
assert_equal('<html><div lapillus:id="component"/></html>', output)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_hierarchy_mismatch__id_in_html_not_in_component_hierarchy
|
|
22
|
+
webpage = Webpage.new
|
|
23
|
+
html = "<html><div lapillus:id=\"missing_component\"></div></html>"
|
|
24
|
+
assert_raise(RuntimeError){webpage.render(html)}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# def test_hierarchy_mismatch__no_id_in_html_component_hierarchy
|
|
28
|
+
# webpage = Webpage.new
|
|
29
|
+
# webpage.add(Component.new("missing_id"))
|
|
30
|
+
# html = "<html></html>"
|
|
31
|
+
# assert_raise(RuntimeError){webpage.render(html)}
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
end
|
data/test/tc_lapillus.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'lapillus'
|
|
3
|
+
include Lapillus
|
|
4
|
+
|
|
5
|
+
class TC_lapillus < Test::Unit::TestCase
|
|
6
|
+
class FormValue
|
|
7
|
+
attr_accessor :variable
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class MyForm < Form
|
|
11
|
+
attr_reader :value
|
|
12
|
+
textfield "textfield"
|
|
13
|
+
def initialize(id)
|
|
14
|
+
super(id)
|
|
15
|
+
@value = FormValue.new
|
|
16
|
+
end
|
|
17
|
+
def on_submit(button=nil)
|
|
18
|
+
value.variable = "value submitted"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_form
|
|
23
|
+
testpage = Webpage.new
|
|
24
|
+
testpage.add(MyForm.new("form"))
|
|
25
|
+
form = testpage["form"]
|
|
26
|
+
form.on_submit
|
|
27
|
+
assert_equal("value submitted", form.value.variable)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'lapillus'
|
|
3
|
+
require 'lapillus/lapillus_testers'
|
|
4
|
+
|
|
5
|
+
include Lapillus
|
|
6
|
+
|
|
7
|
+
@@testObject=nil
|
|
8
|
+
|
|
9
|
+
class TestObject
|
|
10
|
+
attr_accessor :name, :title
|
|
11
|
+
|
|
12
|
+
def initialize(_name, _title)
|
|
13
|
+
@name=_name
|
|
14
|
+
@title=_title
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class LapillusTesterTestPage < Webpage
|
|
19
|
+
label "label", :model => "Label Text"
|
|
20
|
+
|
|
21
|
+
def initialize()
|
|
22
|
+
@@testObject = TestObject.new("Naam","Titel")
|
|
23
|
+
super()
|
|
24
|
+
add(TestForm.new("form", @@testObject))
|
|
25
|
+
add(BookmarkablePageLink.new("link",LinkedPage,Hash.new))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class TestForm < Form
|
|
29
|
+
attr_reader :test_object
|
|
30
|
+
textfield "name", :model => :test_object, :property => :name
|
|
31
|
+
textfield "title", :model => :test_object, :property => :title
|
|
32
|
+
def initialize(id, test_object)
|
|
33
|
+
super(id)
|
|
34
|
+
@test_object = test_object
|
|
35
|
+
end
|
|
36
|
+
def on_submit(button)
|
|
37
|
+
test_object.name = "button 2 is clicked!" if button == "button 2"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class LinkedPage < Webpage
|
|
44
|
+
|
|
45
|
+
def initialize(pageparameters)
|
|
46
|
+
super()
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class TC_LapillusTester < Test::Unit::TestCase
|
|
51
|
+
|
|
52
|
+
@tester
|
|
53
|
+
|
|
54
|
+
def setup
|
|
55
|
+
@tester = LapillusTester.new
|
|
56
|
+
@tester.start_page(LapillusTesterTestPage)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# LapillusTester tests
|
|
60
|
+
def test_assert_component
|
|
61
|
+
@tester.assert_component("form",Form)
|
|
62
|
+
@tester.assert_component("form:name",TextField)
|
|
63
|
+
@tester.assert_component("form:title",TextField)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_assert_label
|
|
67
|
+
@tester.assert_component("label",Label)
|
|
68
|
+
@tester.assert_label("label","Label Text")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_assert_rendered_page
|
|
72
|
+
@tester.assert_rendered_page(LapillusTesterTestPage)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# def test_assert_page_link
|
|
76
|
+
# @tester.assert_page_link("link",LinkedPage)
|
|
77
|
+
# end
|
|
78
|
+
|
|
79
|
+
def test_get_component_from_last_rendered_page
|
|
80
|
+
component = @tester.get_component_from_last_rendered_page("label")
|
|
81
|
+
assert_kind_of(Label, component)
|
|
82
|
+
component = @tester.get_component_from_last_rendered_page("form:name")
|
|
83
|
+
assert_kind_of(TextField, component)
|
|
84
|
+
assert_raise(RuntimeError) do
|
|
85
|
+
component = @tester.get_component_from_last_rendered_page("path:to:nowhere")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# FormTester tests
|
|
90
|
+
def test_set_value
|
|
91
|
+
form_tester = @tester.new_form_tester("form")
|
|
92
|
+
assert_equal("Naam",@@testObject.name)
|
|
93
|
+
assert_equal("Titel",@@testObject.title)
|
|
94
|
+
|
|
95
|
+
form_tester.set_value("name","new_name")
|
|
96
|
+
form_tester.set_value("title","new_title")
|
|
97
|
+
form_tester.submit
|
|
98
|
+
assert_equal("new_name",@@testObject.name)
|
|
99
|
+
assert_equal("new_title",@@testObject.title)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_two_submit_buttons
|
|
103
|
+
form_tester = @tester.new_form_tester("form")
|
|
104
|
+
form_tester.set_value("name","jantje")
|
|
105
|
+
form_tester.submit("button 2")
|
|
106
|
+
assert_equal("button 2 is clicked!", @@testObject.name)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'lapillus/multiview'
|
|
3
|
+
|
|
4
|
+
class TC_MultiView < Test::Unit::TestCase
|
|
5
|
+
def test_current_view
|
|
6
|
+
view1 = SingleView.new("show")
|
|
7
|
+
view2 = SingleView.new("edit")
|
|
8
|
+
multi_view = MultiView.new("id", [view1, view2])
|
|
9
|
+
assert_equal(view1.identifier, multi_view.mode)
|
|
10
|
+
assert_equal(view1, multi_view.current_view)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_mode
|
|
14
|
+
view1 = SingleView.new("show")
|
|
15
|
+
view2 = SingleView.new("edit")
|
|
16
|
+
multi_view = MultiView.new("id", [view1, view2])
|
|
17
|
+
multi_view.mode = "edit"
|
|
18
|
+
assert_equal(view2, multi_view.current_view)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# def test_behaviours
|
|
22
|
+
# html = <<EOF
|
|
23
|
+
# <html>
|
|
24
|
+
# <span lapillus:id="multiview">single_view comes here</span>
|
|
25
|
+
# <lapillus:fragment lapillus:id="single1">
|
|
26
|
+
# <span lapillus:id="label">some content here</span>
|
|
27
|
+
# </lapillus:fragment>
|
|
28
|
+
# <lapillus:fragment lapillus:id="single2">
|
|
29
|
+
# <a lapillus:id="link" href="#">
|
|
30
|
+
# <span lapillus:id="link_label">some content here</span>
|
|
31
|
+
# </a>
|
|
32
|
+
# </lapillus:fragment>
|
|
33
|
+
# </html>
|
|
34
|
+
#EOF
|
|
35
|
+
# single1 = SingleView.new("single1") do
|
|
36
|
+
# add(Label.new("label", "simple label"))
|
|
37
|
+
# end
|
|
38
|
+
# multi_view = MultiView.new("multiview", [single1])
|
|
39
|
+
# multi_view.value = "single1"
|
|
40
|
+
# multi_view.add_behaviour(OnClick.new)
|
|
41
|
+
# page = Webpage.new
|
|
42
|
+
# page.add multi_view
|
|
43
|
+
# output = page.render(html)
|
|
44
|
+
# puts output
|
|
45
|
+
# end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# def xtest_switch_view
|
|
57
|
+
# single1 = SingleView.new("single1") do
|
|
58
|
+
# add(Label.new("label", "simple label"))
|
|
59
|
+
# end
|
|
60
|
+
# single2 = SingleView.new("single2") do
|
|
61
|
+
# add(AjaxLink.new("link") do
|
|
62
|
+
# add(Label.new("link_label", "text inside link"))
|
|
63
|
+
# on_click do
|
|
64
|
+
#
|
|
65
|
+
# end
|
|
66
|
+
# end)
|
|
67
|
+
# end
|
|
68
|
+
# multi_view = MultiView.new("multiview", [single1, single2])
|
|
69
|
+
# multi_view.value = "single1"
|
|
70
|
+
# html = <<EOF
|
|
71
|
+
# <html>
|
|
72
|
+
# <span lapillus:id="multiview">single_view comes here</span>
|
|
73
|
+
# <lapillus:fragment lapillus:id="single1">
|
|
74
|
+
# <span lapillus:id="label">some content here</span>
|
|
75
|
+
# </lapillus:fragment>
|
|
76
|
+
# <lapillus:fragment lapillus:id="single2">
|
|
77
|
+
# <a lapillus:id="link" href="#">
|
|
78
|
+
# <span lapillus:id="link_label">some content here</span>
|
|
79
|
+
# </a>
|
|
80
|
+
# </lapillus:fragment>
|
|
81
|
+
# </html>
|
|
82
|
+
#EOF
|
|
83
|
+
# page = Webpage.new
|
|
84
|
+
# page.add multi_view
|
|
85
|
+
# output = page.render(html)
|
|
86
|
+
# puts output
|
|
87
|
+
# assert_equal(single1,multi_view.get_single_view('single1'))
|
|
88
|
+
# end
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
end
|
data/test/tc_pager.rb
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'lapillus/pager'
|
|
3
|
+
|
|
4
|
+
#component tester
|
|
5
|
+
class ComponentTester
|
|
6
|
+
def initialize(component)
|
|
7
|
+
@component = component
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def assert_label(expected, path)
|
|
11
|
+
actual = @component[path].value
|
|
12
|
+
val = expected == actual
|
|
13
|
+
raise "Label not found! expected: #{expected}, but was #{actual}" if !val
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def click_link(path)
|
|
17
|
+
@component[path].on_click
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class TC_Pager < Test::Unit::TestCase
|
|
22
|
+
attr_reader :pager, :tester
|
|
23
|
+
def setup
|
|
24
|
+
pages = [ "first page", "second page", "third page", "fourth page" ]
|
|
25
|
+
@pager = Pager.new("pager", pages) do |page_content|
|
|
26
|
+
add(Label.new("content", page_content))
|
|
27
|
+
end
|
|
28
|
+
@tester = ComponentTester.new(pager)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_content
|
|
32
|
+
tester.assert_label("first page", "page.content")
|
|
33
|
+
tester.click_link("navigation.next")
|
|
34
|
+
tester.assert_label("second page", "page.content")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_no_content
|
|
38
|
+
pager = Pager.new("pager", []) do end
|
|
39
|
+
assert(!pager['page'].visible?)
|
|
40
|
+
assert(!pager['navigation'].visible?)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_navigation_position
|
|
44
|
+
pager.current = 2
|
|
45
|
+
tester.assert_label("2 van 4", 'navigation.position')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_navigation_next
|
|
49
|
+
tester.click_link('navigation.next')
|
|
50
|
+
assert_equal(2, pager.current)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_navigation_panel_previous
|
|
54
|
+
pager.current = 2
|
|
55
|
+
tester.click_link('navigation.previous')
|
|
56
|
+
assert_equal(1, pager.current)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_navigation_panel_first
|
|
60
|
+
pager.current = 3
|
|
61
|
+
tester.click_link('navigation.first')
|
|
62
|
+
assert_equal(1, pager.current)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_navigation_panel_last
|
|
66
|
+
pager.current = 1
|
|
67
|
+
tester.click_link('navigation.last')
|
|
68
|
+
assert_equal(4, pager.current)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_navigation_visible_last_page
|
|
72
|
+
pager.current = 4
|
|
73
|
+
first_link = pager['navigation.first']
|
|
74
|
+
previous_link = pager['navigation.previous']
|
|
75
|
+
next_link = pager['navigation.next']
|
|
76
|
+
last_link = pager['navigation.last']
|
|
77
|
+
assert(first_link.visible?)
|
|
78
|
+
assert(previous_link.visible?)
|
|
79
|
+
assert(!next_link.visible?)
|
|
80
|
+
assert(!last_link.visible?)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_navigation_visible_first_page
|
|
84
|
+
first_link = pager['navigation.first']
|
|
85
|
+
previous_link = pager['navigation.previous']
|
|
86
|
+
next_link = pager['navigation.next']
|
|
87
|
+
last_link = pager['navigation.last']
|
|
88
|
+
assert(!first_link.visible?)
|
|
89
|
+
assert(!previous_link.visible?)
|
|
90
|
+
assert(next_link.visible?)
|
|
91
|
+
assert(last_link.visible?)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'lapillus'
|
|
3
|
+
|
|
4
|
+
class TestWebpage < Webpage
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class TC_Rendering < Test::Unit::TestCase
|
|
8
|
+
def test_invisible_component
|
|
9
|
+
html='<html><span lapillus:id="label">can you see me now?</span></html>'
|
|
10
|
+
page = TestWebpage.new
|
|
11
|
+
page.add(Label.new("label","now you see me"))
|
|
12
|
+
label = page["label"]
|
|
13
|
+
assert(label.visible?)
|
|
14
|
+
result=page.render(html)
|
|
15
|
+
assert(result.index("now you see me"))
|
|
16
|
+
label.visible=false
|
|
17
|
+
result=page.render(html)
|
|
18
|
+
assert(!result.index("can you see me now?"))
|
|
19
|
+
assert(!result.index("now you see me"))
|
|
20
|
+
assert(!label.visible?)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_label
|
|
24
|
+
html = <<EOF
|
|
25
|
+
<html>
|
|
26
|
+
<body>
|
|
27
|
+
<span lapillus:id="label">here comes the text</span>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
30
|
+
EOF
|
|
31
|
+
expected = <<EOF
|
|
32
|
+
<html>
|
|
33
|
+
<body>
|
|
34
|
+
<span lapillus:id="label">hello world</span>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
EOF
|
|
38
|
+
test_webpage = TestWebpage.new
|
|
39
|
+
test_webpage.add Label.new("label", "hello world")
|
|
40
|
+
output = test_webpage.render html
|
|
41
|
+
assert_equal(expected.strip, output)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class RenderingTestWebpage < Webpage
|
|
45
|
+
listview "names", :model => ["jantje", "pietje", "klaasje"] do |name|
|
|
46
|
+
label "name", :model => name
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_listview
|
|
51
|
+
html = <<EOF
|
|
52
|
+
<html>
|
|
53
|
+
<body>
|
|
54
|
+
<div lapillus:id="names"><span lapillus:id="name">name</span>
|
|
55
|
+
</div>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
EOF
|
|
59
|
+
expected = <<EOF
|
|
60
|
+
<html>
|
|
61
|
+
<body>
|
|
62
|
+
<div lapillus:id="names"><span lapillus:id="name">jantje</span>
|
|
63
|
+
<span lapillus:id="name">pietje</span>
|
|
64
|
+
<span lapillus:id="name">klaasje</span>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
68
|
+
EOF
|
|
69
|
+
test_webpage = RenderingTestWebpage.new
|
|
70
|
+
output = test_webpage.render(html)
|
|
71
|
+
assert_equal(expected.strip, output)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
data/test/ts_all_test.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'test/tc_lapillus'
|
|
3
|
+
require 'test/tc_base'
|
|
4
|
+
require 'test/tc_dispatcher'
|
|
5
|
+
require 'test/tc_components'
|
|
6
|
+
require 'test/tc_containers'
|
|
7
|
+
require 'test/tc_behaviours'
|
|
8
|
+
require 'test/tc_rendering'
|
|
9
|
+
require 'test/tc_bookmarkablepagelink'
|
|
10
|
+
require 'test/tc_form'
|
|
11
|
+
require 'test/tc_lapillus_testers'
|
|
12
|
+
require 'test/tc_fragments'
|
|
13
|
+
require 'test/tc_multiview'
|
|
14
|
+
require 'test/tc_examples'
|
|
15
|
+
require 'test/tc_pager'
|
|
16
|
+
require 'test/tc_hierarchy'
|
|
17
|
+
|
|
18
|
+
require 'examples/tc_guest_book'
|
|
19
|
+
require 'examples/tc_hello_world'
|
|
20
|
+
require 'examples/tc_persons'
|
metadata
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
rubygems_version: 0.9.4
|
|
3
|
+
specification_version: 1
|
|
4
|
+
name: lapillus
|
|
5
|
+
version: !ruby/object:Gem::Version
|
|
6
|
+
version: 0.0.2
|
|
7
|
+
date: 2007-10-05 00:00:00 +02:00
|
|
8
|
+
summary: Component based webframework written in Ruby
|
|
9
|
+
require_paths:
|
|
10
|
+
- lib
|
|
11
|
+
email: ronald.dekker@huygensinstituut.knaw.nl
|
|
12
|
+
homepage:
|
|
13
|
+
rubyforge_project:
|
|
14
|
+
description:
|
|
15
|
+
autorequire: lapillus
|
|
16
|
+
default_executable:
|
|
17
|
+
bindir: bin
|
|
18
|
+
has_rdoc: false
|
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">"
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.0.0
|
|
24
|
+
version:
|
|
25
|
+
platform: ruby
|
|
26
|
+
signing_key:
|
|
27
|
+
cert_chain:
|
|
28
|
+
post_install_message:
|
|
29
|
+
authors:
|
|
30
|
+
- Bram Buitendijk
|
|
31
|
+
- Ronald Haentjens Dekker
|
|
32
|
+
- Meindert Kroese
|
|
33
|
+
- Joris van Zundert
|
|
34
|
+
files:
|
|
35
|
+
- examples/hello_world.rb
|
|
36
|
+
- examples/persons.rb
|
|
37
|
+
- examples/tc_hello_world.rb
|
|
38
|
+
- examples/tc_guest_book.rb
|
|
39
|
+
- examples/guest_book.rb
|
|
40
|
+
- examples/tc_persons.rb
|
|
41
|
+
- html/HelloWorld.html
|
|
42
|
+
- html/GuestBook.html
|
|
43
|
+
- html/Persons.html
|
|
44
|
+
- html/LapillusTesterTestPage.html
|
|
45
|
+
- html/TestRemotePanel.html
|
|
46
|
+
- html/TestPage.html
|
|
47
|
+
- lib/lapillus.rb
|
|
48
|
+
- lib/changelog.txt
|
|
49
|
+
- lib/license.txt
|
|
50
|
+
- lib/lapillus
|
|
51
|
+
- lib/lapillus/web_application.rb
|
|
52
|
+
- lib/lapillus/webrick_server.rb
|
|
53
|
+
- lib/lapillus/process_upload.rb
|
|
54
|
+
- lib/lapillus/pager.rb
|
|
55
|
+
- lib/lapillus/form_components.rb
|
|
56
|
+
- lib/lapillus/lapillus_testers.rb
|
|
57
|
+
- lib/lapillus/behaviours.rb
|
|
58
|
+
- lib/lapillus/multiview.rb
|
|
59
|
+
- lib/lapillus/containers.rb
|
|
60
|
+
- lib/lapillus/components.rb
|
|
61
|
+
- lib/lapillus/mongrel_server.rb
|
|
62
|
+
- lib/lapillus/dispatcher.rb
|
|
63
|
+
- lib/lapillus/base.rb
|
|
64
|
+
- lib/lapillus/lapillus_server.rb
|
|
65
|
+
- test/ts_all_test.rb
|
|
66
|
+
- test/tc_rendering.rb
|
|
67
|
+
- test/tc_base.rb
|
|
68
|
+
- test/tc_behaviours.rb
|
|
69
|
+
- test/tc_fragments.rb
|
|
70
|
+
- test/tc_pager.rb
|
|
71
|
+
- test/tc_containers.rb
|
|
72
|
+
- test/tc_components.rb
|
|
73
|
+
- test/tc_bookmarkablepagelink.rb
|
|
74
|
+
- test/tc_multiview.rb
|
|
75
|
+
- test/tc_lapillus_testers.rb
|
|
76
|
+
- test/tc_dispatcher.rb
|
|
77
|
+
- test/tc_hierarchy.rb
|
|
78
|
+
- test/tc_form.rb
|
|
79
|
+
- test/tc_examples.rb
|
|
80
|
+
- test/tc_lapillus.rb
|
|
81
|
+
test_files:
|
|
82
|
+
- test/ts_all_test.rb
|
|
83
|
+
rdoc_options: []
|
|
84
|
+
|
|
85
|
+
extra_rdoc_files: []
|
|
86
|
+
|
|
87
|
+
executables: []
|
|
88
|
+
|
|
89
|
+
extensions: []
|
|
90
|
+
|
|
91
|
+
requirements: []
|
|
92
|
+
|
|
93
|
+
dependencies: []
|
|
94
|
+
|