Skip to content

Commit 164f89f

Browse files
committed
More complex recursive graph framing test.
1 parent 3714197 commit 164f89f

File tree

1 file changed

+171
-6
lines changed

1 file changed

+171
-6
lines changed

spec/frame_spec.rb

Lines changed: 171 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@
14261426
end
14271427

14281428
it "issue #28" do
1429-
input = JSON.parse %({
1429+
input = %({
14301430
"@context": {
14311431
"rdfs": "http://www.w3.org/2000/01/rdf-schema#"
14321432
},
@@ -1443,7 +1443,7 @@
14431443
}
14441444
]
14451445
})
1446-
frame = JSON.parse %({
1446+
frame = %({
14471447
"@context": {
14481448
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
14491449
"talksAbout": {
@@ -1457,7 +1457,7 @@
14571457
},
14581458
"@id": "http://www.myresource/uuid"
14591459
})
1460-
expected = JSON.parse %({
1460+
expected = %({
14611461
"@context": {
14621462
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
14631463
"talksAbout": {
@@ -1483,7 +1483,7 @@
14831483
end
14841484

14851485
it "framing with @version: 1.1 prunes identifiers" do
1486-
input = JSON.parse %({
1486+
input = %({
14871487
"@context": {
14881488
"@version": 1.1,
14891489
"@vocab": "https://example.com#",
@@ -1499,7 +1499,7 @@
14991499
"test": "foo"
15001500
}
15011501
})
1502-
frame = JSON.parse %({
1502+
frame = %({
15031503
"@context": {
15041504
"@version": 1.1,
15051505
"@vocab": "https://example.com#",
@@ -1512,7 +1512,7 @@
15121512
},
15131513
"claim": {}
15141514
})
1515-
expected = JSON.parse %({
1515+
expected = %({
15161516
"@context": {
15171517
"@version": 1.1,
15181518
"@vocab": "https://example.com#",
@@ -1534,6 +1534,171 @@
15341534
})
15351535
do_frame(input: input, frame: frame, output: expected, processingMode: 'json-ld-1.1')
15361536
end
1537+
1538+
it "PR #663" do
1539+
input = %({
1540+
"@context": {
1541+
"@vocab": "http://example.com/",
1542+
"loves": {
1543+
"@type": "@id"
1544+
},
1545+
"unionOf": {
1546+
"@type": "@id",
1547+
"@id": "owl:unionOf",
1548+
"@container": "@list"
1549+
},
1550+
"Class": "owl:Class"
1551+
},
1552+
"@graph": [
1553+
{
1554+
"@type": "Act",
1555+
"@graph": [
1556+
{
1557+
"@id": "Romeo",
1558+
"@type": "Person"
1559+
},
1560+
{
1561+
"@id": "Juliet",
1562+
"@type": "Person"
1563+
}
1564+
]
1565+
},
1566+
{
1567+
"@id": "ActTwo",
1568+
"@type": "Act",
1569+
"@graph": [
1570+
{
1571+
"@id": "Romeo",
1572+
"@type": "Person",
1573+
"loves": "Juliet"
1574+
},
1575+
{
1576+
"@id": "Juliet",
1577+
"@type": "Person",
1578+
"loves": "Romeo"
1579+
}
1580+
]
1581+
},
1582+
{
1583+
"@id": "Person",
1584+
"@type": "Class",
1585+
"unionOf": {
1586+
"@list": [
1587+
{
1588+
"@id": "Montague",
1589+
"@type": "Class"
1590+
},
1591+
{
1592+
"@id": "Capulet",
1593+
"@type": "Class"
1594+
}
1595+
]
1596+
}
1597+
}
1598+
]
1599+
})
1600+
frame = %({
1601+
"@context": {
1602+
"@vocab": "http://example.com/",
1603+
"loves": {
1604+
"@type": "@id"
1605+
},
1606+
"unionOf": {
1607+
"@type": "@id",
1608+
"@id": "owl:unionOf",
1609+
"@container": "@list"
1610+
},
1611+
"Class": "owl:Class"
1612+
},
1613+
"@graph": [
1614+
{
1615+
"@explicit": false,
1616+
"@embed": "@last",
1617+
"@type": [
1618+
"Act",
1619+
"Class"
1620+
],
1621+
"@graph": [{
1622+
"@explicit": true,
1623+
"@embed": "@always",
1624+
"@type": "Person",
1625+
"@id": {},
1626+
"loves": {"@embed": "@never"}
1627+
}]
1628+
}
1629+
]
1630+
})
1631+
expected = %({
1632+
"@context": {
1633+
"@vocab": "http://example.com/",
1634+
"loves": {
1635+
"@type": "@id"
1636+
},
1637+
"unionOf": {
1638+
"@type": "@id",
1639+
"@id": "owl:unionOf",
1640+
"@container": "@list"
1641+
},
1642+
"Class": "owl:Class"
1643+
},
1644+
"@graph": [
1645+
{
1646+
"@graph": [
1647+
{
1648+
"@id": "Juliet",
1649+
"@type": "Person",
1650+
"loves": "Romeo"
1651+
},
1652+
{
1653+
"@id": "Romeo",
1654+
"@type": "Person",
1655+
"loves": "Juliet"
1656+
}
1657+
],
1658+
"@id": "ActTwo",
1659+
"@type": "Act"
1660+
},
1661+
{
1662+
"@id": "Capulet",
1663+
"@type": "Class"
1664+
},
1665+
{
1666+
"@id": "Montague",
1667+
"@type": "Class"
1668+
},
1669+
{
1670+
"@id": "Person",
1671+
"@type": "Class",
1672+
"unionOf": [
1673+
{
1674+
"@id": "Montague",
1675+
"@type": "Class"
1676+
},
1677+
{
1678+
"@id": "Capulet",
1679+
"@type": "Class"
1680+
}
1681+
]
1682+
},
1683+
{
1684+
"@graph": [
1685+
{
1686+
"@id": "Juliet",
1687+
"@type": "Person",
1688+
"loves": null
1689+
},
1690+
{
1691+
"@id": "Romeo",
1692+
"@type": "Person",
1693+
"loves": null
1694+
}
1695+
],
1696+
"@type": "Act"
1697+
}
1698+
]
1699+
})
1700+
do_frame(input: input, frame: frame, output: expected, processingMode: 'json-ld-1.1')
1701+
end
15371702
end
15381703

15391704
def do_frame(params)

0 commit comments

Comments
 (0)