Skip to content

Commit f40d0b0

Browse files
committed
update test
1 parent 07dc894 commit f40d0b0

File tree

7 files changed

+22
-33
lines changed

7 files changed

+22
-33
lines changed

.github/workflows/ci_jruby.yml

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ jobs:
1717
ruby-version: ${{ matrix.ruby }}
1818
bundler-cache: true
1919
- run: bundle exec rake
20+
env:
21+
JRUBY_OPTS: --profile

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ Gemfile.lock
1010
*.swp
1111
*.swo
1212
bin
13+
# Jetbrains IDEs
14+
.idea
15+
*.iml
16+
/out

test/as_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AsXmlTest < MiniTest::Spec
5858
end
5959

6060
it do
61-
assert_equal "<album>
61+
assert_xml_equal "<album>
6262
<combo>
6363
<name>Offspring</name>
6464
</combo>

test/cached_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def self.profile(&block)
2222
printer = JRuby::Profiler::FlatProfilePrinter.new(profile_result)
2323
printer.printProfile(print_stream)
2424
output_stream.toString
25+
when 'truffleruby'
26+
require 'truffleruby-tool'
27+
28+
output = StringIO.new
29+
TruffleRubyTool.profile(&block)
30+
output.string
2531
end
2632
end
2733
end

test/test_helper.rb

-15
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,6 @@ def parse(object, input, *args)
7272
object.send("from_#{format}", input, *args)
7373
end
7474

75-
class AssertableDocument
76-
attr_reader :document
77-
78-
def initialize(document, format)
79-
@document = document
80-
@format = format
81-
end
82-
83-
def must_equal_document(*args)
84-
return document.must_equal_xml(*args) if @format == :xml
85-
86-
document.must_equal(*args)
87-
end
88-
end
89-
9075
def self.representer!(options = {}, &block)
9176
fmt = options # we need that so the 2nd call to ::let(within a ::describe) remembers the right format.
9277

test/wrap_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class AlbumDecorator < Representable::Decorator
149149

150150
# band has wrap turned of per property definition, however, label still has wrap.
151151
it 'rendersxx' do
152-
assert_equal("<albums>
152+
assert_xml_equal("<albums>
153153
<po>
154154
<po>
155155
<name>Social Distortion</name>

test/xml_namespace_test.rb

+8-16
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,12 @@ class Library < Representable::Decorator
136136
# :map-class end
137137

138138
it 'renders' do
139+
139140
assert_equal(
140-
Library.new(Model::Library.new(book)).to_xml,
141141
# :map-xml
142-
%(<lib:library xmlns:lib="http://eric.van-der-vlist.com/ns/library" xmlns:hr="http://eric.van-der-vlist.com/ns/person">
143-
<lib:book id="1">
144-
<lib:isbn>666</lib:isbn>
145-
<hr:author>
146-
<hr:name>Fowler</hr:name>
147-
</hr:author>
148-
<lib:character>
149-
<lib:qualification>typed</lib:qualification>
150-
<hr:name>Frau Java</hr:name>
151-
<hr:born>1991</hr:born>
152-
</lib:character>
153-
</lib:book>
154-
</lib:library>)
142+
"<lib:library xmlns:lib=\"http://eric.van-der-vlist.com/ns/library\" xmlns:hr=\"http://eric.van-der-vlist.com/ns/person\">\n <lib:book id=\"1\">\n <lib:isbn>666</lib:isbn>\n <hr:author>\n <hr:name>Fowler</hr:name>\n </hr:author>\n <lib:character>\n <lib:qualification>typed</lib:qualification>\n <hr:name>Frau Java</hr:name>\n <hr:born>1991</hr:born>\n </lib:character>\n </lib:book>\n</lib:library>",
155143
# :map-xml end
144+
Library.new(Model::Library.new(book)).to_xml
156145
)
157146
end
158147

@@ -180,10 +169,13 @@ class Library < Representable::Decorator
180169
# :parse-call end
181170
)
182171

183-
_(lib.book.inspect).must_equal %(#<struct Namespace2XMLTest::Model::Book id=\"1\", isbn=\"666\", author=#<struct Namespace2XMLTest::Model::Character name=\"Fowler\", born=nil, qualification=nil>, character=[#<struct Namespace2XMLTest::Model::Character name=\"Frau Java\", born=\"1991\", qualification=\"typed\">]>)
172+
#take last line only
173+
xml = lib.book.inspect
174+
expected = "#<struct Namespace2XMLTest::Model::Book id=\"1\", isbn=\"666\", author=#<struct Namespace2XMLTest::Model::Character name=\"Fowler\", born=nil, qualification=nil>, character=[#<struct Namespace2XMLTest::Model::Character name=\"Frau Java\", born=\"1991\", qualification=\"typed\">]>"
184175

176+
assert_equal(expected, xml.to_s)
185177
# :parse-res
186-
lib.book.character[0].name #=> "Frau Java"
178+
assert_equal "Frau Java", lib.book.character[0].name
187179
# :parse-res end
188180
end
189181
end

0 commit comments

Comments
 (0)