Skip to content

Commit 7be1e48

Browse files
committed
Added unit test for Image element
1 parent 7c933f9 commit 7be1e48

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.magneticflux.rss
2+
3+
class UrlUtils {
4+
static URL testUrl() {
5+
return new URL('http://www.example.com')
6+
}
7+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.github.magneticflux.rss.namespaces.standard.elements
2+
3+
import com.github.magneticflux.rss.PersisterSpecification
4+
import spock.lang.Unroll
5+
6+
import static com.github.magneticflux.rss.UrlUtils.testUrl
7+
8+
class ImageTest extends PersisterSpecification {
9+
@Unroll
10+
def 'enclosure #object read/write'() {
11+
12+
expect: 'the output XML equals the given XML'
13+
persister.write(object) == xml
14+
15+
and: 'the input object equals the given object'
16+
persister.read(Image, xml) == object
17+
18+
where:
19+
url | title | link | description | widthRaw | heightRaw | xml
20+
testUrl() | 'testTitle' | testUrl() | 'testDescription' | '100' | '100' | """<image>
21+
| <url>$url</url>
22+
| <title>$title</title>
23+
| <link>$link</link>
24+
| <description>$description</description>
25+
| <width>$widthRaw</width>
26+
| <height>$heightRaw</height>
27+
|</image>""".stripMargin()
28+
29+
testUrl() | 'testTitle' | testUrl() | null | '100' | '100' | """<image>
30+
| <url>$url</url>
31+
| <title>$title</title>
32+
| <link>$link</link>
33+
| <width>$widthRaw</width>
34+
| <height>$heightRaw</height>
35+
|</image>""".stripMargin()
36+
37+
testUrl() | 'testTitle' | testUrl() | 'testDescription' | null | '100' | """<image>
38+
| <url>$url</url>
39+
| <title>$title</title>
40+
| <link>$link</link>
41+
| <description>$description</description>
42+
| <height>$heightRaw</height>
43+
|</image>""".stripMargin()
44+
45+
testUrl() | 'testTitle' | testUrl() | 'testDescription' | '100' | null | """<image>
46+
| <url>$url</url>
47+
| <title>$title</title>
48+
| <link>$link</link>
49+
| <description>$description</description>
50+
| <width>$widthRaw</width>
51+
|</image>""".stripMargin()
52+
53+
object = new Image(url, title, link, description, widthRaw, heightRaw)
54+
}
55+
}

0 commit comments

Comments
 (0)