markaby 0.8.1 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/.ruby-version +1 -1
- data/.travis.yml +12 -0
- data/CHANGELOG.rdoc +19 -0
- data/Gemfile +11 -5
- data/Gemfile.lock +68 -11
- data/LICENSE +19 -0
- data/Markaby.gemspec +12 -16
- data/README.rdoc +143 -25
- data/Rakefile +30 -24
- data/lib/markaby/builder.rb +58 -100
- data/lib/markaby/builder_tags.rb +8 -10
- data/lib/markaby/cssproxy.rb +5 -5
- data/lib/markaby/html5.rb +118 -0
- data/lib/markaby/kernel_method.rb +4 -3
- data/lib/markaby/rails.rb +36 -0
- data/lib/markaby/tagset.rb +89 -0
- data/lib/markaby/version.rb +5 -1
- data/lib/markaby/xhtml_frameset.rb +13 -0
- data/lib/markaby/xhtml_strict.rb +89 -0
- data/lib/markaby/xhtml_transitional.rb +61 -0
- data/lib/markaby/xml_tagset.rb +19 -0
- data/lib/markaby.rb +5 -4
- data/spec/markaby/builder_spec.rb +1 -1
- data/spec/markaby/css_proxy_spec.rb +13 -12
- data/spec/markaby/fragment_spec.rb +1 -1
- data/spec/markaby/html5_spec.rb +74 -25
- data/spec/markaby/markaby_spec.rb +71 -91
- data/spec/markaby/markaby_test_unit_spec.rb +98 -127
- data/spec/markaby/rails_spec.rb +29 -0
- data/spec/spec_helper.rb +19 -20
- metadata +21 -20
- data/lib/markaby/tags.rb +0 -288
@@ -0,0 +1,61 @@
|
|
1
|
+
require "markaby/xml_tagset"
|
2
|
+
require "markaby/xhtml_strict"
|
3
|
+
module Markaby
|
4
|
+
# Additional tags found in XHTML 1.0 Transitional
|
5
|
+
class XHTMLTransitional < XmlTagset
|
6
|
+
@doctype = ["-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]
|
7
|
+
@tagset = XHTMLStrict.tagset.merge({
|
8
|
+
strike: Attrs,
|
9
|
+
center: Attrs,
|
10
|
+
dir: Attrs + [:compact],
|
11
|
+
noframes: Attrs,
|
12
|
+
basefont: [:id, :size, :color, :face],
|
13
|
+
u: Attrs,
|
14
|
+
menu: Attrs + [:compact],
|
15
|
+
iframe: AttrCore + [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :scrolling, :align, :height, :width],
|
16
|
+
font: AttrCore + AttrI18n + [:size, :color, :face],
|
17
|
+
s: Attrs,
|
18
|
+
applet: AttrCore + [:codebase, :archive, :code, :object, :alt, :name, :width, :height, :align, :hspace, :vspace],
|
19
|
+
isindex: AttrCore + AttrI18n + [:prompt]
|
20
|
+
})
|
21
|
+
|
22
|
+
# Additional attributes found in XHTML 1.0 Transitional
|
23
|
+
additional_tags = {
|
24
|
+
script: [:language],
|
25
|
+
a: [:target],
|
26
|
+
td: [:bgcolor, :nowrap, :width, :height],
|
27
|
+
p: [:align],
|
28
|
+
h5: [:align],
|
29
|
+
h3: [:align],
|
30
|
+
li: [:type, :value],
|
31
|
+
div: [:align],
|
32
|
+
pre: [:width],
|
33
|
+
body: [:background, :bgcolor, :text, :link, :vlink, :alink],
|
34
|
+
ol: [:type, :compact, :start],
|
35
|
+
h4: [:align],
|
36
|
+
h2: [:align],
|
37
|
+
object: [:align, :border, :hspace, :vspace],
|
38
|
+
img: [:name, :align, :border, :hspace, :vspace],
|
39
|
+
link: [:target],
|
40
|
+
legend: [:align],
|
41
|
+
dl: [:compact],
|
42
|
+
input: [:align],
|
43
|
+
h6: [:align],
|
44
|
+
hr: [:align, :noshade, :size, :width],
|
45
|
+
base: [:target],
|
46
|
+
ul: [:type, :compact],
|
47
|
+
br: [:clear],
|
48
|
+
form: [:name, :target],
|
49
|
+
area: [:target],
|
50
|
+
h1: [:align]
|
51
|
+
}
|
52
|
+
|
53
|
+
additional_tags.each do |k, v|
|
54
|
+
@tagset[k] += v
|
55
|
+
end
|
56
|
+
|
57
|
+
@tags = @tagset.keys
|
58
|
+
@forms = @tags & FORM_TAGS
|
59
|
+
@self_closing = @tags & SELF_CLOSING_TAGS
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "markaby/tagset"
|
2
|
+
module Markaby
|
3
|
+
# Additional tags found in XHTML 1.0 Frameset
|
4
|
+
class XmlTagset < Tagset
|
5
|
+
class << self
|
6
|
+
def default_options
|
7
|
+
super.merge({
|
8
|
+
output_xml_instruction: true,
|
9
|
+
output_meta_tag: "xhtml",
|
10
|
+
root_attributes: {
|
11
|
+
xmlns: "http://www.w3.org/1999/xhtml",
|
12
|
+
"xml:lang": "en",
|
13
|
+
lang: "en"
|
14
|
+
}
|
15
|
+
})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/markaby.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# as well as the full set of Markaby classes.
|
5
5
|
#
|
6
6
|
# For a full list of features and instructions, see the README.
|
7
|
-
$:.unshift
|
7
|
+
$:.unshift __dir__
|
8
8
|
|
9
9
|
# Markaby is a module containing all of the great Markaby classes that
|
10
10
|
# do such an excellent job.
|
@@ -21,6 +21,7 @@ module Markaby
|
|
21
21
|
end
|
22
22
|
|
23
23
|
require "markaby/version"
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
24
|
+
require "builder" unless defined?(Builder)
|
25
|
+
require "markaby/tagset"
|
26
|
+
require "markaby/builder"
|
27
|
+
require "markaby/cssproxy"
|
@@ -9,34 +9,35 @@ describe Markaby::CssProxy do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def mock_builder
|
12
|
-
|
13
|
-
def tag!(*args)
|
12
|
+
Class.new do
|
13
|
+
def tag!(*args)
|
14
|
+
end
|
14
15
|
end.new
|
15
16
|
end
|
16
17
|
|
17
18
|
it "responds_to_everything" do
|
18
|
-
proxy = Markaby::CssProxy.new(mock_builder,
|
19
|
-
proxy.respond_to?(:any_method).should
|
20
|
-
proxy.respond_to?(:foobarbazasdfasdfadfs).should
|
19
|
+
proxy = Markaby::CssProxy.new(mock_builder, "stream", :sym)
|
20
|
+
proxy.respond_to?(:any_method).should be true
|
21
|
+
proxy.respond_to?(:foobarbazasdfasdfadfs).should be true
|
21
22
|
end
|
22
23
|
|
23
24
|
it "does_not_respond_to_method_missing" do
|
24
|
-
proxy = Markaby::CssProxy.new(mock_builder,
|
25
|
+
proxy = Markaby::CssProxy.new(mock_builder, "stream", :sym)
|
25
26
|
proxy.should_not respond_to(:method_missing)
|
26
27
|
end
|
27
28
|
|
28
29
|
it "does_respond_to_private_instance_methods_with_private_flag_set_to_true" do
|
29
|
-
proxy = Markaby::CssProxy.new(mock_builder,
|
30
|
-
proxy.respond_to?(:method_missing, true).should
|
30
|
+
proxy = Markaby::CssProxy.new(mock_builder, "stream", :sym)
|
31
|
+
proxy.respond_to?(:method_missing, true).should be true
|
31
32
|
end
|
32
33
|
|
33
34
|
it "does_not_respond_to_private_instance_methods_with_private_flag_set_to_false" do
|
34
|
-
proxy = Markaby::CssProxy.new(mock_builder,
|
35
|
-
proxy.respond_to?(:method_missing, false).should
|
35
|
+
proxy = Markaby::CssProxy.new(mock_builder, "stream", :sym)
|
36
|
+
proxy.respond_to?(:method_missing, false).should be false
|
36
37
|
end
|
37
38
|
|
38
39
|
it "respond_to_should_always_return_boolean" do
|
39
|
-
proxy = Markaby::CssProxy.new(mock_builder,
|
40
|
-
proxy.respond_to?(:method_missing, :a_value).should
|
40
|
+
proxy = Markaby::CssProxy.new(mock_builder, "stream", :sym)
|
41
|
+
proxy.respond_to?(:method_missing, :a_value).should be true
|
41
42
|
end
|
42
43
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
|
-
|
3
|
+
describe "Fragments" do
|
4
4
|
it "should have method_missing as a private instance method" do
|
5
5
|
private_methods = Markaby::Fragment.private_instance_methods.dup
|
6
6
|
private_methods.map! { |m| m.to_sym }
|
data/spec/markaby/html5_spec.rb
CHANGED
@@ -2,12 +2,12 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
2
|
|
3
3
|
describe Markaby do
|
4
4
|
it "should insert an html5 doctype" do
|
5
|
-
document = mab { html5 { head { title
|
5
|
+
document = mab { html5 { head { title "OKay" } } }
|
6
6
|
document.should include("<!DOCTYPE html>")
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should not have xmlns in html5 html tag" do
|
10
|
-
document = mab { html5 { head { title
|
10
|
+
document = mab { html5 { head { title "OKay" } } }
|
11
11
|
document.should_not include("xmlns")
|
12
12
|
end
|
13
13
|
|
@@ -27,12 +27,14 @@ describe Markaby do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should put correct xhtml charset meta" do
|
30
|
-
document = mab { xhtml_strict { head { title
|
31
|
-
document.should include(
|
30
|
+
document = mab { xhtml_strict { head { title "OKay" } } }
|
31
|
+
document.should include("<meta")
|
32
|
+
document.should include('http-equiv="Content-Type"')
|
33
|
+
document.should include('content="text/html; charset=utf-8"')
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should put correct html5 charset meta" do
|
35
|
-
document = mab { html5 { head { title
|
37
|
+
document = mab { html5 { head { title "OKay" } } }
|
36
38
|
document.should include('<meta charset="utf-8"/>')
|
37
39
|
end
|
38
40
|
|
@@ -48,38 +50,42 @@ describe Markaby do
|
|
48
50
|
|
49
51
|
it "should add a closing slash to self-closing tags in xhtml" do
|
50
52
|
document = mab { br }
|
51
|
-
document.should include(
|
53
|
+
document.should include("<br/>")
|
52
54
|
end
|
53
55
|
|
54
|
-
it "should not add a closing slash to self-closing tags in html5" do
|
55
|
-
|
56
|
-
document = mab { html5 { br } }
|
57
|
-
document.should include('<br>')
|
58
|
-
end
|
59
|
-
end
|
56
|
+
# it "should not add a closing slash to self-closing tags in html5" do
|
57
|
+
# pending
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
# document = mab { html5 { br } }
|
60
|
+
# document.should include("<br>")
|
61
|
+
# end
|
62
|
+
|
63
|
+
# it "should close empty non-self-closing tags in html5" do
|
64
|
+
# pending
|
65
|
+
# document = mab { html5 { header } }
|
66
|
+
# document.should include("<header></header>")
|
67
|
+
# end
|
68
|
+
|
69
|
+
it "should allow custom elements" do
|
70
|
+
document = mab { html5 { my_custom_element(id: "mce-123") { "Hello" } } }
|
71
|
+
document.should include("<my-custom-element id=\"mce-123\">Hello</my-custom-element>")
|
66
72
|
end
|
67
73
|
|
68
74
|
it "should not allow fake attributes" do
|
69
75
|
expect {
|
70
76
|
mab do
|
71
77
|
html5 do
|
72
|
-
input "something", :
|
78
|
+
input "something", fake: "fake", foo: "bar"
|
73
79
|
end
|
74
80
|
end
|
75
|
-
}.to raise_error
|
81
|
+
}.to raise_error(Markaby::InvalidXhtmlError)
|
76
82
|
end
|
77
83
|
|
78
84
|
it "should allow new attributes" do
|
79
85
|
expect {
|
80
86
|
mab do
|
81
87
|
html5 do
|
82
|
-
input "something", :
|
88
|
+
input "something", placeholder: "placeholder"
|
83
89
|
end
|
84
90
|
end
|
85
91
|
}.not_to raise_error
|
@@ -88,13 +94,56 @@ describe Markaby do
|
|
88
94
|
it "should allow a placeholder on an input" do
|
89
95
|
doc = mab do
|
90
96
|
html5 do
|
91
|
-
input :
|
92
|
-
|
93
|
-
|
94
|
-
|
97
|
+
input type: "text",
|
98
|
+
name: "foo",
|
99
|
+
value: "bar",
|
100
|
+
placeholder: "something"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
doc.should include('<input type="text" ')
|
105
|
+
doc.should include('name="foo"')
|
106
|
+
doc.should include('value="bar"')
|
107
|
+
doc.should include('placeholder="something"')
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should allow data attributes anywhere" do
|
111
|
+
doc = mab do
|
112
|
+
html5 do
|
113
|
+
div("data-foo" => "bar")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
doc.should include('<div data-foo="bar"/>')
|
118
|
+
end
|
119
|
+
|
120
|
+
it "expands data attributes provided as a hash" do
|
121
|
+
doc = mab do
|
122
|
+
html5 do
|
123
|
+
div(data: {foo: "bar"})
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
doc.should include('<div data-foo="bar"/>')
|
128
|
+
end
|
129
|
+
|
130
|
+
it "dasherises data attributes provided as a hash" do
|
131
|
+
doc = mab do
|
132
|
+
html5 do
|
133
|
+
div(data: {some_attribute: "value"})
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
doc.should include('<div data-some-attribute="value"/>')
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should allow aria attributes everywhere" do
|
141
|
+
doc = mab do
|
142
|
+
html5 do
|
143
|
+
div("aria-foo" => "bar")
|
95
144
|
end
|
96
145
|
end
|
97
146
|
|
98
|
-
doc.should
|
147
|
+
doc.should include('<div aria-foo="bar"/>')
|
99
148
|
end
|
100
149
|
end
|
@@ -1,8 +1,19 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
3
|
describe Markaby do
|
4
|
+
it "should work with classes and ids" do
|
5
|
+
mab { div.one "" }.should == %(<div class="one"></div>)
|
6
|
+
mab { div.one.two "" }.should == %(<div class="one two"></div>)
|
7
|
+
mab { div.three! "" }.should == %(<div id="three"></div>)
|
8
|
+
mab { hr.hidden }.should == %(<hr class="hidden"/>)
|
9
|
+
|
10
|
+
out = mab { input.foo id: "bar" }
|
11
|
+
out.should match("<input.*class=\"foo\".*/>")
|
12
|
+
out.should match("<input.*name=\"bar\".*/>")
|
13
|
+
end
|
14
|
+
|
4
15
|
it "can assign helpers after instantiation" do
|
5
|
-
helper = double
|
16
|
+
helper = double "helper", foo: :bar
|
6
17
|
|
7
18
|
builder = Markaby::Builder.new
|
8
19
|
builder.helper = helper
|
@@ -11,35 +22,31 @@ describe Markaby do
|
|
11
22
|
|
12
23
|
it "should be able to set a local" do
|
13
24
|
builder = Markaby::Builder.new
|
14
|
-
builder.locals = {
|
25
|
+
builder.locals = {foo: "bar"}
|
15
26
|
builder.foo.should == "bar"
|
16
27
|
end
|
17
28
|
|
18
29
|
it "should be able to set a different local value" do
|
19
30
|
builder = Markaby::Builder.new
|
20
|
-
builder.locals = {
|
31
|
+
builder.locals = {foo: "baz"}
|
21
32
|
builder.foo.should == "baz"
|
22
33
|
end
|
23
34
|
|
24
35
|
it "should assign the correct key" do
|
25
36
|
builder = Markaby::Builder.new
|
26
|
-
builder.locals = {
|
37
|
+
builder.locals = {key: :value}
|
27
38
|
builder.key.should == :value
|
28
39
|
end
|
29
40
|
|
30
41
|
it "should be able to assign multiple locals" do
|
31
42
|
builder = Markaby::Builder.new
|
32
43
|
|
33
|
-
builder.locals = {
|
44
|
+
builder.locals = {one: "two", three: "four"}
|
34
45
|
|
35
46
|
builder.one.should == "two"
|
36
47
|
builder.three.should == "four"
|
37
48
|
end
|
38
49
|
|
39
|
-
def test_builder_bang_methods
|
40
|
-
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", mab { instruct! }
|
41
|
-
end
|
42
|
-
|
43
50
|
it "should be able to produce the correct html from a fragment" do
|
44
51
|
str = ""
|
45
52
|
str += "<div>"
|
@@ -53,115 +60,89 @@ describe Markaby do
|
|
53
60
|
div {
|
54
61
|
h1 "Monkeys"
|
55
62
|
h2 {
|
56
|
-
"Giraffes #{small(
|
63
|
+
"Giraffes #{small("Miniature")} and #{strong "Large"}"
|
57
64
|
}
|
58
65
|
h3 "Donkeys"
|
59
|
-
h4 { "Parakeet #{b { i
|
66
|
+
h4 { "Parakeet #{b { i "Innocent IV" }} in Classic Chartreuse" }
|
60
67
|
}
|
61
68
|
}
|
62
69
|
|
63
70
|
generated.should == str
|
64
71
|
end
|
65
72
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_invalid_xhtml
|
75
|
-
assert_exception(NoMethodError, "undefined method `dav'") { dav {} }
|
76
|
-
assert_exception(Markaby::InvalidXhtmlError, "no attribute `styl' on div elements") { div(:styl => 'ok') {} }
|
77
|
-
assert_exception(Markaby::InvalidXhtmlError, "no attribute `class' on tbody elements") { tbody.okay {} }
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_full_doc_transitional
|
81
|
-
doc = mab { xhtml_transitional { head { title 'OKay' } } }
|
82
|
-
assert doc =~ /^<\?xml version="1.0" encoding="UTF-8"\?>/
|
83
|
-
assert doc.include?(%{"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">})
|
84
|
-
assert doc.include?(%{<title>OKay</title>})
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_full_doc_strict
|
88
|
-
doc = mab { xhtml_strict { head { title 'OKay' } } }
|
89
|
-
assert doc =~ /^<\?xml version="1.0" encoding="UTF-8"\?>/
|
90
|
-
assert doc.include?(%{"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">})
|
91
|
-
assert doc.include?(%{<title>OKay</title>})
|
92
|
-
end
|
73
|
+
it "should copy instance variables from a helper object" do
|
74
|
+
klass = Class.new do
|
75
|
+
def initialize
|
76
|
+
@hello = "hello there"
|
77
|
+
end
|
78
|
+
end
|
93
79
|
|
94
|
-
|
95
|
-
|
96
|
-
assert doc =~ /^<\?xml version="1.0" encoding="UTF-8"\?>/
|
97
|
-
assert doc.include?(%{"-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">})
|
98
|
-
assert doc.include?(%{<title>OKay</title>})
|
80
|
+
builder = Markaby::Builder.new({}, klass.new)
|
81
|
+
builder.capture { @hello }.should == "hello there"
|
99
82
|
end
|
100
83
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
assert doc.include?(%{ lang="fr"})
|
84
|
+
describe Markaby::InvalidXhtmlError do
|
85
|
+
it "should inherit from StandardError" do
|
86
|
+
Markaby::InvalidXhtmlError.superclass.should == StandardError
|
87
|
+
end
|
106
88
|
end
|
107
89
|
|
108
|
-
|
109
|
-
|
110
|
-
end
|
90
|
+
it "can assign helpers after instantiation" do
|
91
|
+
helper = double "helper", foo: :bar
|
111
92
|
|
112
|
-
|
113
|
-
|
93
|
+
builder = Markaby::Builder.new
|
94
|
+
builder.helper = helper
|
95
|
+
builder.foo.should == :bar
|
114
96
|
end
|
115
97
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
p.one!
|
121
|
-
end
|
122
|
-
end
|
98
|
+
it "should be able to set a local" do
|
99
|
+
builder = Markaby::Builder.new
|
100
|
+
builder.locals = {foo: "bar"}
|
101
|
+
builder.foo.should == "bar"
|
123
102
|
end
|
124
103
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
mab do
|
130
|
-
tag! :an_invalid_tag
|
131
|
-
end
|
132
|
-
end
|
104
|
+
it "should be able to set a different local value" do
|
105
|
+
builder = Markaby::Builder.new
|
106
|
+
builder.locals = {foo: "baz"}
|
107
|
+
builder.foo.should == "baz"
|
133
108
|
end
|
134
109
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
110
|
+
it "should assign the correct key" do
|
111
|
+
builder = Markaby::Builder.new
|
112
|
+
builder.locals = {key: :value}
|
113
|
+
builder.key.should == :value
|
142
114
|
end
|
143
115
|
|
144
|
-
|
145
|
-
builder = Markaby::Builder.new
|
116
|
+
it "should be able to assign multiple locals" do
|
117
|
+
builder = Markaby::Builder.new
|
146
118
|
|
147
|
-
|
148
|
-
end
|
119
|
+
builder.locals = {one: "two", three: "four"}
|
149
120
|
|
150
|
-
|
151
|
-
builder
|
152
|
-
assert_equal :a_value, builder.variable
|
121
|
+
builder.one.should == "two"
|
122
|
+
builder.three.should == "four"
|
153
123
|
end
|
154
124
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
125
|
+
it "should be able to produce the correct html from a fragment" do
|
126
|
+
str = ""
|
127
|
+
str += "<div>"
|
128
|
+
str += "<h1>Monkeys</h1>"
|
129
|
+
str += "<h2>Giraffes <small>Miniature</small> and <strong>Large</strong></h2>"
|
130
|
+
str += "<h3>Donkeys</h3>"
|
131
|
+
str += "<h4>Parakeet <b><i>Innocent IV</i></b> in Classic Chartreuse</h4>"
|
132
|
+
str += "</div>"
|
159
133
|
|
160
|
-
|
161
|
-
|
134
|
+
generated = mab {
|
135
|
+
div {
|
136
|
+
h1 "Monkeys"
|
137
|
+
h2 {
|
138
|
+
"Giraffes #{small("Miniature")} and #{strong "Large"}"
|
139
|
+
}
|
140
|
+
h3 "Donkeys"
|
141
|
+
h4 { "Parakeet #{b { i "Innocent IV" }} in Classic Chartreuse" }
|
142
|
+
}
|
143
|
+
}
|
162
144
|
|
163
|
-
|
164
|
-
builder.something.should == "<something/>"
|
145
|
+
generated.should == str
|
165
146
|
end
|
166
147
|
|
167
148
|
it "should copy instance variables from a helper object" do
|
@@ -181,4 +162,3 @@ describe Markaby do
|
|
181
162
|
end
|
182
163
|
end
|
183
164
|
end
|
184
|
-
|