eim_xml 0.0.3 → 1.0.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.
- checksums.yaml +7 -0
- data/LICENSE +339 -0
- data/lib/eim_xml/assertions.rb +14 -14
- data/lib/eim_xml/dsl.rb +104 -96
- data/lib/eim_xml/formatter/element_wrapper.rb +9 -0
- data/lib/eim_xml/formatter.rb +107 -97
- data/lib/eim_xml/matcher.rb +23 -20
- data/lib/eim_xml/parser.rb +68 -70
- data/lib/eim_xml/xhtml/dsl.rb +16 -14
- data/lib/eim_xml/xhtml.rb +156 -134
- data/lib/eim_xml.rb +202 -202
- metadata +30 -59
- data/Rakefile +0 -23
- data/Rakefile.utirake +0 -334
- data/spec/assertions_spec.rb +0 -29
- data/spec/dsl_spec.rb +0 -217
- data/spec/eim_xml_spec.rb +0 -441
- data/spec/formatter_spec.rb +0 -215
- data/spec/parser_spec.rb +0 -102
- data/spec/xhtml_spec.rb +0 -490
data/Rakefile.utirake
DELETED
@@ -1,334 +0,0 @@
|
|
1
|
-
# Utility for Rake
|
2
|
-
#
|
3
|
-
# Copyright (C) 2008, KURODA Hiraku <hiraku@hinet.mydns.jp>
|
4
|
-
# You can redistribute it and/or modify it under GPL3.
|
5
|
-
|
6
|
-
require "rake/clean"
|
7
|
-
require "rake/testtask"
|
8
|
-
require "rake/rdoctask"
|
9
|
-
require "rake/gempackagetask"
|
10
|
-
require "rake/contrib/rubyforgepublisher"
|
11
|
-
require "rubygems/package_task"
|
12
|
-
|
13
|
-
class UtiRake
|
14
|
-
def self.setup(opt={}, &proc)
|
15
|
-
ur = new
|
16
|
-
ur.setup(opt, &proc)
|
17
|
-
rescue
|
18
|
-
puts $!.class, $!.message, $!.backtrace
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_reader :opt, :spec_proc, :cucumber_proc, :rdoc_proc, :gemspec_proc, :package_proc, :rcov_spec_proc
|
22
|
-
|
23
|
-
def setup(opt={}, &proc)
|
24
|
-
@opt = opt
|
25
|
-
directory "external"
|
26
|
-
CLOBBER << "external" << "coverage" << "coverage.spec" << "coverage.cuke" << "doc"
|
27
|
-
|
28
|
-
instance_eval(&proc) if proc
|
29
|
-
|
30
|
-
if need_spec?
|
31
|
-
require "spec/rake/spectask"
|
32
|
-
define_spec_task
|
33
|
-
end
|
34
|
-
|
35
|
-
if need_cucumber?
|
36
|
-
require "cucumber/rake/task"
|
37
|
-
define_cucumber_task
|
38
|
-
end
|
39
|
-
|
40
|
-
define_rdoc_task
|
41
|
-
define_rcov_task
|
42
|
-
define_package_task
|
43
|
-
define_here_dependency
|
44
|
-
define_alias_task if @alias_task
|
45
|
-
end
|
46
|
-
|
47
|
-
def need_spec?
|
48
|
-
File.directory?("spec")
|
49
|
-
end
|
50
|
-
|
51
|
-
def need_cucumber?
|
52
|
-
File.directory?("features")
|
53
|
-
end
|
54
|
-
|
55
|
-
def spec(&proc)
|
56
|
-
@spec_proc = proc
|
57
|
-
end
|
58
|
-
|
59
|
-
def cucumber(&proc)
|
60
|
-
@cucumber_proc = proc
|
61
|
-
end
|
62
|
-
|
63
|
-
def rdoc(&proc)
|
64
|
-
@rdoc_proc = proc
|
65
|
-
end
|
66
|
-
|
67
|
-
def gemspec(&proc)
|
68
|
-
@gemspec_proc = proc
|
69
|
-
end
|
70
|
-
|
71
|
-
def rcov_spec(&proc)
|
72
|
-
@rcov_spec_proc = proc
|
73
|
-
end
|
74
|
-
|
75
|
-
def package(&proc)
|
76
|
-
@package_proc = proc
|
77
|
-
end
|
78
|
-
|
79
|
-
def no_here(task)
|
80
|
-
@no_here_task = task
|
81
|
-
end
|
82
|
-
|
83
|
-
def no_here_task
|
84
|
-
@no_here_task || "spec:lump"
|
85
|
-
end
|
86
|
-
|
87
|
-
def alias_task
|
88
|
-
@alias_task = true
|
89
|
-
end
|
90
|
-
|
91
|
-
def hg(cmd)
|
92
|
-
sh "hg #{cmd.to_s}"
|
93
|
-
end
|
94
|
-
|
95
|
-
def external(base_url, *libs)
|
96
|
-
libs = libs.first if libs.first.is_a?(Array)
|
97
|
-
namespace :external do
|
98
|
-
directory "external/lib"
|
99
|
-
libs.each do |lib|
|
100
|
-
libdir = "external/#{lib}"
|
101
|
-
file libdir => "external/lib" do
|
102
|
-
if File.exist?("../#{lib}")
|
103
|
-
Dir.chdir("external") do
|
104
|
-
ln_s "../../#{lib}", "./", :force=>true
|
105
|
-
end
|
106
|
-
end
|
107
|
-
hg "clone #{File.join(base_url, lib)} #{libdir}" unless File.exist?(libdir)
|
108
|
-
Dir["#{libdir}/lib/*"].each do |f|
|
109
|
-
base = File.basename(f)
|
110
|
-
cd "external/lib" do
|
111
|
-
ln_s "../#{lib}/lib/#{base}", "./"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
if File.exist?(libdir)
|
117
|
-
Dir["#{libdir}/lib/*"].each do |f|
|
118
|
-
base = File.basename(f)
|
119
|
-
file "external/lib/#{base}" => "external/lib" do
|
120
|
-
cd "external/lib" do
|
121
|
-
ln_s "../#{lib}/lib/#{base}", "./"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
task :setup => "external/lib/#{base}"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
desc "Setup external libraries"
|
129
|
-
task :setup=>libdir
|
130
|
-
end
|
131
|
-
|
132
|
-
task :rake => :setup do
|
133
|
-
libs.each do |lib|
|
134
|
-
Dir.chdir "external/#{lib}" do
|
135
|
-
sh "rake"
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
@external = true
|
141
|
-
end
|
142
|
-
|
143
|
-
def external?; @external; end
|
144
|
-
|
145
|
-
def define_rdoc_task
|
146
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
147
|
-
rdoc.options << "-S"
|
148
|
-
rdoc.options << "-w" << "3"
|
149
|
-
rdoc.options << "-c" << "UTF-8"
|
150
|
-
rdoc.rdoc_files.include("lib/**/*.rb")
|
151
|
-
rdoc_proc.call(rdoc) if rdoc_proc
|
152
|
-
end
|
153
|
-
task :doc do
|
154
|
-
remove_entry_secure "doc" if File.directory?("doc")
|
155
|
-
sh "rdoc -S -w 3 -c UTF-8 -d -x external"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def define_package_task
|
160
|
-
spec = Gem::Specification.new do |s|
|
161
|
-
s.platform = Gem::Platform::RUBY
|
162
|
-
s.files = FileList["Rakefile*", "lib/**/*", "spec/**/*"]
|
163
|
-
s.version = ENV["VER"] || "0.0.0.noversion"
|
164
|
-
gemspec_proc.call(s) if gemspec_proc
|
165
|
-
end
|
166
|
-
|
167
|
-
gem = Gem::PackageTask.new(spec) do |t|
|
168
|
-
t.need_tar_gz = true
|
169
|
-
t.need_zip = true
|
170
|
-
package_proc.call(t) if package_proc
|
171
|
-
end
|
172
|
-
|
173
|
-
task "utirake:gem" do
|
174
|
-
mv "Rakefile.utirake", "Rakefile.utirake_#{$$}"
|
175
|
-
symlink "external/utirake/utirake.rb", "Rakefile.utirake"
|
176
|
-
end
|
177
|
-
|
178
|
-
file "#{gem.package_dir}/#{gem.gem_spec.file_name}" => "utirake:gem"
|
179
|
-
|
180
|
-
task :gem do
|
181
|
-
rm "Rakefile.utirake"
|
182
|
-
mv "Rakefile.utirake_#{$$}", "Rakefile.utirake"
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def publish(project_name, user_id)
|
187
|
-
task :publish => "rdoc" do
|
188
|
-
yield if block_given
|
189
|
-
Rake::RubyForgePublisher.new(project_name, user_id).upload
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
FILE_SORT = lambda{|a, b| File.mtime(a)<=>File.mtime(b)}
|
194
|
-
|
195
|
-
def spec_files
|
196
|
-
@spec_files ||= FileList["./spec/**/*_spec.rb"].sort(&FILE_SORT).reverse
|
197
|
-
end
|
198
|
-
|
199
|
-
def set_spec_opts(spec)
|
200
|
-
spec.spec_opts << "-c"
|
201
|
-
spec.libs << "." << "./lib" << "./external/lib"
|
202
|
-
end
|
203
|
-
|
204
|
-
def define_spec_task
|
205
|
-
task :spec => "spec:apart"
|
206
|
-
namespace :spec do
|
207
|
-
spec_files.each do |f|
|
208
|
-
desc ""
|
209
|
-
Spec::Rake::SpecTask.new(:apart) do |s|
|
210
|
-
s.spec_files = FileList[f]
|
211
|
-
set_spec_opts(s)
|
212
|
-
spec_proc.call(s) if spec_proc
|
213
|
-
end
|
214
|
-
end
|
215
|
-
task(:apart).comment = "Run all specs separately"
|
216
|
-
|
217
|
-
desc "Run all specs in a lump"
|
218
|
-
Spec::Rake::SpecTask.new(:lump) do |s|
|
219
|
-
s.spec_files = spec_files
|
220
|
-
set_spec_opts(s)
|
221
|
-
spec_proc.call(s) if spec_proc
|
222
|
-
end
|
223
|
-
|
224
|
-
desc "Run all specs to profile"
|
225
|
-
Spec::Rake::SpecTask.new(:profile) do |s|
|
226
|
-
set_spec_opts(s)
|
227
|
-
s.spec_opts << "-f" << "profile"
|
228
|
-
end
|
229
|
-
|
230
|
-
`grep -sRn '#[[:space:]]*here[[:space:]]*$' spec`.split(/\n/).map{|l|
|
231
|
-
next nil unless l=~/\A(.*?):(\d+):/
|
232
|
-
[$1, $2.to_i]
|
233
|
-
}.compact.sort{|a, b| FILE_SORT.call(a[0], b[0])}.reverse.each do |file, line|
|
234
|
-
desc ""
|
235
|
-
Spec::Rake::SpecTask.new(:here) do |s|
|
236
|
-
s.spec_files = [file]
|
237
|
-
set_spec_opts(s)
|
238
|
-
s.spec_opts << "-l#{line}"
|
239
|
-
spec_proc.call(s) if spec_proc
|
240
|
-
end
|
241
|
-
end
|
242
|
-
task :no_here => no_here_task
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
def set_cucumber_opts(task)
|
247
|
-
task.libs << "."
|
248
|
-
cucumber_proc.call(task) if cucumber_proc
|
249
|
-
end
|
250
|
-
|
251
|
-
def define_cucumber_task
|
252
|
-
Cucumber::Rake::Task.new do |t|
|
253
|
-
set_cucumber_opts(t)
|
254
|
-
end
|
255
|
-
|
256
|
-
unless `grep -sRn '^[[:space:]]*@here$' features`.empty?
|
257
|
-
Cucumber::Rake::Task.new("cucumber:here") do |t|
|
258
|
-
t.cucumber_opts = %w[--tags @here]
|
259
|
-
set_cucumber_opts(t)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
task "cucumber:no_here" => :cucumber
|
263
|
-
end
|
264
|
-
|
265
|
-
def define_here_dependency
|
266
|
-
unless Rake::Task.task_defined?("spec:here") || Rake::Task.task_defined?("cucumber:here")
|
267
|
-
task "spec:here" => "spec:no_here" if need_spec? && !Rake::Task.task_defined?("spec:here")
|
268
|
-
task "cucumber:here" => "cucumber:no_here" if need_cucumber? && !Rake::Task.task_defined?("cucumber:here")
|
269
|
-
end
|
270
|
-
|
271
|
-
task("spec:here").comment = "Run spec only marked '# here'"
|
272
|
-
task("cucumber:here").comment = "only tagged '@here'"
|
273
|
-
end
|
274
|
-
|
275
|
-
def rcov_opts(t, aggregation)
|
276
|
-
t.rcov_opts << "--exclude" << "gems\/,features\/,external\/"
|
277
|
-
t.rcov_opts << "--aggregate" << "coverage.data" if aggregation
|
278
|
-
t.rcov = true
|
279
|
-
end
|
280
|
-
|
281
|
-
def define_rcov_each_task(aggregation)
|
282
|
-
if need_spec?
|
283
|
-
Spec::Rake::SpecTask.new do |t|
|
284
|
-
t.spec_files = spec_files
|
285
|
-
rcov_opts(t, aggregation)
|
286
|
-
set_spec_opts(t)
|
287
|
-
rcov_spec_proc.call(t) if rcov_spec_proc
|
288
|
-
t.rcov_dir = "coverage.spec" unless aggregation
|
289
|
-
end
|
290
|
-
else
|
291
|
-
task "spec"
|
292
|
-
end
|
293
|
-
|
294
|
-
if need_cucumber?
|
295
|
-
Cucumber::Rake::Task.new do |t|
|
296
|
-
set_cucumber_opts(t)
|
297
|
-
rcov_opts(t, aggregation)
|
298
|
-
t.rcov_opts << "-o" << "coverage.cuke" unless aggregation
|
299
|
-
end
|
300
|
-
else
|
301
|
-
task "cucumber"
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def define_rcov_task
|
306
|
-
namespace :rcov do
|
307
|
-
define_rcov_each_task(false)
|
308
|
-
end
|
309
|
-
|
310
|
-
desc "Run specs and Cucumber using RCov"
|
311
|
-
task "rcov:lump" do
|
312
|
-
rm "coverage.data" if File.exist?("coverage.data")
|
313
|
-
ns = namespace do
|
314
|
-
define_rcov_each_task(true)
|
315
|
-
end
|
316
|
-
ns.tasks.each do |t|
|
317
|
-
t.invoke
|
318
|
-
end
|
319
|
-
rm "coverage.data"
|
320
|
-
end
|
321
|
-
|
322
|
-
task "rcov:all" => %w[rcov:spec rcov:cucumber rcov:lump]
|
323
|
-
end
|
324
|
-
|
325
|
-
def define_alias_task
|
326
|
-
if Rake::Task.task_defined?("spec:apart")
|
327
|
-
task :apart => "spec:apart"
|
328
|
-
task :lump => "spec:lump"
|
329
|
-
task :here => "spec:here"
|
330
|
-
task :profile => "spec:profile"
|
331
|
-
end
|
332
|
-
task :here => "cucumber:here" if Rake::Task.task_defined?("cucumber:here")
|
333
|
-
end
|
334
|
-
end
|
data/spec/assertions_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Test for eim_xml/assertions.rb
|
2
|
-
#
|
3
|
-
# Copyright (C) 2006, KURODA Hiraku <hiraku@hinet.mydns.jp>
|
4
|
-
# You can redistribute it and/or modify it under GPL2.
|
5
|
-
|
6
|
-
require "test/unit"
|
7
|
-
require "eim_xml/assertions"
|
8
|
-
|
9
|
-
class EimXMLAssertionsTest < Test::Unit::TestCase
|
10
|
-
include EimXML
|
11
|
-
include EimXML::Assertions
|
12
|
-
|
13
|
-
def test_assert_has
|
14
|
-
e = Element.new(:tag) do |e|
|
15
|
-
e <<= Element.new(:sub)
|
16
|
-
end
|
17
|
-
|
18
|
-
assert_nothing_raised do
|
19
|
-
assert_has(:sub, e)
|
20
|
-
end
|
21
|
-
|
22
|
-
a = assert_raises(Test::Unit::AssertionFailedError) do
|
23
|
-
assert_has(:no, e)
|
24
|
-
end
|
25
|
-
assert(!a.backtrace.any?{ |i|
|
26
|
-
i=~/eim_xml\/assertions\.rb/
|
27
|
-
})
|
28
|
-
end
|
29
|
-
end
|
data/spec/dsl_spec.rb
DELETED
@@ -1,217 +0,0 @@
|
|
1
|
-
require "eim_xml/dsl"
|
2
|
-
|
3
|
-
module Module.new::M
|
4
|
-
include EimXML
|
5
|
-
EDSL = EimXML::DSL
|
6
|
-
|
7
|
-
describe EimXML::DSL do
|
8
|
-
it "scope is in instance of DSL" do
|
9
|
-
outer = inner = nil
|
10
|
-
e3 = e2 = nil
|
11
|
-
block_executed = false
|
12
|
-
e = EDSL.element(:out, :k1=>"v1") do
|
13
|
-
outer = self
|
14
|
-
e2 = element(:in, :k2=>"v2") do
|
15
|
-
block_executed = true
|
16
|
-
inner = self
|
17
|
-
e3 = element(:deep)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
block_executed.should == true
|
22
|
-
outer.should be_kind_of(EDSL)
|
23
|
-
inner.should be_kind_of(EDSL)
|
24
|
-
outer.should be_equal(inner)
|
25
|
-
|
26
|
-
e.name.should == :out
|
27
|
-
e[:k1].should == "v1"
|
28
|
-
e[0].name.should == :in
|
29
|
-
e[0][:k2].should == "v2"
|
30
|
-
e[0][0].name.should == :deep
|
31
|
-
e2.should be_equal(e[0])
|
32
|
-
e3.should be_equal(e[0][0])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "#comment" do
|
36
|
-
Comment.should_receive(:new).with("comment").and_return(:success)
|
37
|
-
EDSL.comment("comment").should == :success
|
38
|
-
end
|
39
|
-
|
40
|
-
it "#import_variables" do
|
41
|
-
d = EDSL.new
|
42
|
-
o = Object.new
|
43
|
-
o.instance_variable_set("@v1", 1)
|
44
|
-
o.instance_variable_set("@v2", "2")
|
45
|
-
o.instance_variable_set("@_v3", :t)
|
46
|
-
o.instance_variable_set("@__v4", 4)
|
47
|
-
o.instance_variable_set("@_container", :t)
|
48
|
-
orig_c = d.instance_variable_get("@_container")
|
49
|
-
|
50
|
-
d.import_variables(o).should be_equal(d)
|
51
|
-
|
52
|
-
d.instance_variable_get("@_container").should == orig_c
|
53
|
-
d.instance_variables.map(&:to_s).sort.should == ["@v1", "@v2", "@__v4"].sort
|
54
|
-
d.instance_variable_get("@v1").should == 1
|
55
|
-
d.instance_variable_get("@v2").should == "2"
|
56
|
-
d.instance_variable_get("@__v4").should == 4
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#_push" do
|
60
|
-
before do
|
61
|
-
m = Module.new
|
62
|
-
class m::D < EimXML::DSL
|
63
|
-
def call_push(c)
|
64
|
-
_push(c) do
|
65
|
-
element(:e)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def exec
|
70
|
-
element(:e) do
|
71
|
-
element(:f)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
@D = m::D
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should return given container" do
|
79
|
-
a = []
|
80
|
-
@D.new.call_push(a).should be_equal(a)
|
81
|
-
a.should == [EimXML::Element.new(:e)]
|
82
|
-
|
83
|
-
@D.new.exec.should == EimXML::Element.new(:e).add(EimXML::Element.new(:f))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "Subclass of BaseDSL" do
|
89
|
-
class DSL1 < EimXML::BaseDSL
|
90
|
-
register([EimXML::Element, "call"])
|
91
|
-
register(Hash)
|
92
|
-
register(String, Array, Object)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "register" do
|
96
|
-
lambda{EDSL.call(:dummy)}.should raise_error(NoMethodError)
|
97
|
-
lambda{BaseDSL.call(:dummy)}.should raise_error(NoMethodError)
|
98
|
-
lambda{DSL1.element(:dummy)}.should raise_error(NoMethodError)
|
99
|
-
DSL1.call(:dummy).should be_kind_of(Element)
|
100
|
-
DSL1.hash.should be_kind_of(Hash)
|
101
|
-
DSL1.string.should be_kind_of(String)
|
102
|
-
DSL1.array.should be_kind_of(Array)
|
103
|
-
DSL1.object.should be_kind_of(Object)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe EimXML::OpenDSL do
|
108
|
-
it "scope of block is one of outside" do
|
109
|
-
@scope_checker_variable = 1
|
110
|
-
block_executed = false
|
111
|
-
d = OpenDSL.new do |d|
|
112
|
-
block_executed = true
|
113
|
-
d.should be_kind_of(OpenDSL)
|
114
|
-
d.container.should be_nil
|
115
|
-
d.element(:base, :key1=>"v1") do
|
116
|
-
@scope_checker_variable.should == 1
|
117
|
-
self.should_not be_kind_of(Element)
|
118
|
-
d.container.should be_kind_of(Element)
|
119
|
-
d.container.should == Element.new(:base, :key1=>"v1")
|
120
|
-
d.element(:sub, :key2=>"v2") do
|
121
|
-
d.container.should be_kind_of(Element)
|
122
|
-
d.container.should == Element.new(:sub, :key2=>"v2")
|
123
|
-
end
|
124
|
-
d.element(:sub2).should == Element.new(:sub2)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
block_executed.should be_true
|
128
|
-
end
|
129
|
-
|
130
|
-
it "DSL methods return element" do
|
131
|
-
d = OpenDSL.new
|
132
|
-
d.container.should be_nil
|
133
|
-
r = d.element(:base, :key1=>"v1") do
|
134
|
-
d.element(:sub, :key2=>"v2")
|
135
|
-
end
|
136
|
-
r.should == EDSL.element(:base, :key1=>"v1") do
|
137
|
-
element(:sub, :key2=>"v2")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
it "DSL method's block given instance of OpenDSL" do
|
142
|
-
e = OpenDSL.new.element(:base) do |d|
|
143
|
-
d.should be_kind_of(OpenDSL)
|
144
|
-
d.container.name.should == :base
|
145
|
-
d.element(:sub) do |d2|
|
146
|
-
d2.should be_equal(d)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
e.should == EDSL.element(:base) do
|
151
|
-
element(:sub)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
it "ensure reset container when error raised" do
|
156
|
-
OpenDSL.new do |d|
|
157
|
-
begin
|
158
|
-
d.element(:base) do
|
159
|
-
begin
|
160
|
-
d.element(:sub) do
|
161
|
-
raise "OK"
|
162
|
-
end
|
163
|
-
rescue RuntimeError => e
|
164
|
-
raise unless e.message=="OK"
|
165
|
-
d.container.name.should == :base
|
166
|
-
raise
|
167
|
-
end
|
168
|
-
end
|
169
|
-
rescue RuntimeError => e
|
170
|
-
raise unless e.message=="OK"
|
171
|
-
d.container.should == nil
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
it "respond to add" do
|
177
|
-
r = OpenDSL.new.element(:base) do |d|
|
178
|
-
d.add "text"
|
179
|
-
d.element(:sub) do
|
180
|
-
s = Element.new(:sub)
|
181
|
-
s.add("sub text")
|
182
|
-
d.add("sub text").should == s
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
r.should == EDSL.element(:base) do
|
187
|
-
add "text"
|
188
|
-
element(:sub) do
|
189
|
-
add "sub text"
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
it "respond to <<" do
|
195
|
-
r = OpenDSL.new.element(:base) do |d|
|
196
|
-
b = Element.new(:base)
|
197
|
-
b << "text" << "next"
|
198
|
-
(d << "text" << "next").should == b
|
199
|
-
end
|
200
|
-
r.should == EDSL.element(:base) do
|
201
|
-
add "text"
|
202
|
-
add "next"
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
it "can call directly element method" do
|
207
|
-
r = OpenDSL.element(:base) do |d|
|
208
|
-
d.element(:sub)
|
209
|
-
d.element(:sub2)
|
210
|
-
end
|
211
|
-
r.should == EDSL.element(:base) do
|
212
|
-
element(:sub)
|
213
|
-
element(:sub2)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|