We can have indented heredoc now \o/

This commit is contained in:
Benjamin Neff 2019-10-19 04:12:09 +02:00
parent 1dfe57ea7e
commit 1570fff040
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
39 changed files with 1452 additions and 1460 deletions

View file

@ -199,11 +199,3 @@ Style/DateTime:
Exclude: Exclude:
- "lib/diaspora_federation/discovery/xrd_document.rb" - "lib/diaspora_federation/discovery/xrd_document.rb"
- "spec/lib/diaspora_federation/discovery/xrd_document_spec.rb" - "spec/lib/diaspora_federation/discovery/xrd_document_spec.rb"
### backward compatibility
# only with ruby >= 2.3
Layout/IndentHeredoc:
Enabled: false
Layout/ClosingHeredocIndentation:
Enabled: false

View file

@ -2,7 +2,7 @@
module DiasporaFederation module DiasporaFederation
describe Entities::Relayable do describe Entities::Relayable do
let(:author_serialized_key) { <<-KEY } let(:author_serialized_key) { <<~KEY }
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh
btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr
@ -27,7 +27,7 @@ KEY
# g6zpg1zxGahpmxwqFQIDAQAB # g6zpg1zxGahpmxwqFQIDAQAB
# -----END PUBLIC KEY----- # -----END PUBLIC KEY-----
let(:parent_serialized_key) { <<-KEY } let(:parent_serialized_key) { <<~KEY }
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/ MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/
F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx
@ -65,7 +65,7 @@ KEY
) )
} }
let(:legacy_format_comment_xml_alice) { <<-XML } let(:legacy_format_comment_xml_alice) { <<~XML }
<XML> <XML>
<post> <post>
<comment> <comment>
@ -79,7 +79,7 @@ KEY
</post> </post>
</XML> </XML>
XML XML
let(:new_format_comment_xml_alice) { <<-XML } let(:new_format_comment_xml_alice) { <<~XML }
<comment> <comment>
<author>alice@pod-a.org</author> <author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -89,7 +89,7 @@ XML
<parent_author_signature/> <parent_author_signature/>
</comment> </comment>
XML XML
let(:new_data_comment_xml_alice) { <<-XML } let(:new_data_comment_xml_alice) { <<~XML }
<comment> <comment>
<author>alice@pod-a.org</author> <author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -101,7 +101,7 @@ XML
</comment> </comment>
XML XML
let(:legacy_format_comment_xml_bob) { <<-XML } let(:legacy_format_comment_xml_bob) { <<~XML }
<XML> <XML>
<post> <post>
<comment> <comment>
@ -115,7 +115,7 @@ XML
</post> </post>
</XML> </XML>
XML XML
let(:legacy_order_new_format_comment_xml_bob) { <<-XML } let(:legacy_order_new_format_comment_xml_bob) { <<~XML }
<comment> <comment>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>
<parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid> <parent_guid>9e269ae0b41201333b8c0f77ba60fa73</parent_guid>
@ -125,7 +125,7 @@ XML
<parent_author_signature>QqWSdwpb+/dcJUxuKKVe7aiz1NivXzlIdWZ71xyrxnhFxFYd+7EIittyTcp1cVehjg96pwDbn++P/rWyCffqenWu025DHvUfSmQkC93Z0dX6r3OIUlZqwEggtOdbunybiE++F3BVsGt5wC4YbAESB5ZFuhFVhBXh1X+EaZ/qoKo=</parent_author_signature> <parent_author_signature>QqWSdwpb+/dcJUxuKKVe7aiz1NivXzlIdWZ71xyrxnhFxFYd+7EIittyTcp1cVehjg96pwDbn++P/rWyCffqenWu025DHvUfSmQkC93Z0dX6r3OIUlZqwEggtOdbunybiE++F3BVsGt5wC4YbAESB5ZFuhFVhBXh1X+EaZ/qoKo=</parent_author_signature>
</comment> </comment>
XML XML
let(:new_order_legacy_format_comment_xml_bob) { <<-XML } let(:new_order_legacy_format_comment_xml_bob) { <<~XML }
<XML> <XML>
<post> <post>
<comment> <comment>
@ -139,7 +139,7 @@ XML
</post> </post>
</XML> </XML>
XML XML
let(:new_format_comment_xml_bob) { <<-XML } let(:new_format_comment_xml_bob) { <<~XML }
<comment> <comment>
<author>alice@pod-a.org</author> <author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -149,7 +149,7 @@ XML
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature> <parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
</comment> </comment>
XML XML
let(:legacy_format_new_data_comment_xml_bob) { <<-XML } let(:legacy_format_new_data_comment_xml_bob) { <<~XML }
<XML> <XML>
<post> <post>
<comment> <comment>
@ -164,7 +164,7 @@ XML
</post> </post>
</XML> </XML>
XML XML
let(:new_data_comment_xml_bob) { <<-XML } let(:new_data_comment_xml_bob) { <<~XML }
<comment> <comment>
<author>alice@pod-a.org</author> <author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>

View file

@ -23,7 +23,7 @@ module DiasporaFederation
} }
} }
let(:html) { <<-HTML } let(:html) { <<~HTML }
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
@ -136,7 +136,7 @@ HTML
end end
it "reads minimal hCard" do it "reads minimal hCard" do
minimal_html = <<-HTML minimal_html = <<~HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
@ -261,7 +261,7 @@ HTML
end end
it "fails if the document is incomplete" do it "fails if the document is incomplete" do
invalid_html = <<-HTML invalid_html = <<~HTML
<div id="content"> <div id="content">
<span class="fn">#{person.full_name}</span> <span class="fn">#{person.full_name}</span>
</div> </div>

View file

@ -3,7 +3,7 @@
module DiasporaFederation module DiasporaFederation
describe Discovery::HostMeta do describe Discovery::HostMeta do
let(:base_url) { "https://pod.example.tld/" } let(:base_url) { "https://pod.example.tld/" }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}.well-known/webfinger.xml?resource={uri}"/> <Link rel="lrdd" type="application/xrd+xml" template="#{base_url}.well-known/webfinger.xml?resource={uri}"/>
@ -42,7 +42,7 @@ XML
end end
it "also reads old-style XML" do it "also reads old-style XML" do
historic_xml = <<-XML historic_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
@ -59,7 +59,7 @@ XML
end end
it "also reads friendica/redmatrix XML" do it "also reads friendica/redmatrix XML" do
friendica_redmatrix_xml = <<-XML friendica_redmatrix_xml = <<~XML
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' <XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:hm='http://host-meta.net/xrd/1.0'> xmlns:hm='http://host-meta.net/xrd/1.0'>
@ -77,7 +77,7 @@ XML
end end
it "fails if the document does not contain a webfinger url" do it "fails if the document does not contain a webfinger url" do
invalid_xml = <<XML invalid_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
</XRD> </XRD>
@ -86,7 +86,7 @@ XML
end end
it "fails if the document contains a malformed webfinger url" do it "fails if the document contains a malformed webfinger url" do
invalid_xml = <<XML invalid_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q="/> <Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q="/>

View file

@ -18,7 +18,7 @@ module DiasporaFederation
} }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>#{acct}</Subject> <Subject>#{acct}</Subject>
@ -32,7 +32,7 @@ module DiasporaFederation
</XRD> </XRD>
XML XML
let(:minimal_xml) { <<-XML } let(:minimal_xml) { <<~XML }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>#{acct}</Subject> <Subject>#{acct}</Subject>
@ -41,7 +41,7 @@ XML
</XRD> </XRD>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"subject": "#{acct}", "subject": "#{acct}",
"aliases": [ "aliases": [
@ -80,7 +80,7 @@ XML
} }
JSON JSON
let(:minimal_json) { <<-JSON } let(:minimal_json) { <<~JSON }
{ {
"subject": "#{acct}", "subject": "#{acct}",
"links": [ "links": [
@ -132,7 +132,7 @@ JSON
end end
it "creates XML document with additional data" do it "creates XML document with additional data" do
xml_with_additional_data = <<-XML xml_with_additional_data = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>#{acct}</Subject> <Subject>#{acct}</Subject>
@ -164,7 +164,7 @@ XML
end end
it "creates JSON document with additional data" do it "creates JSON document with additional data" do
json_with_additional_data = <<-JSON json_with_additional_data = <<~JSON
{ {
"subject": "#{acct}", "subject": "#{acct}",
"aliases": [ "aliases": [
@ -251,7 +251,7 @@ JSON
end end
it "reads friendica XML (two aliases, first with acct)" do it "reads friendica XML (two aliases, first with acct)" do
friendica_xml = <<-XML friendica_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
@ -308,7 +308,7 @@ JSON
end end
it "reads redmatrix XML (no alias)" do it "reads redmatrix XML (no alias)" do
redmatrix_xml = <<-XML redmatrix_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
@ -349,7 +349,7 @@ JSON
end end
it "fails if the document is empty" do it "fails if the document is empty" do
invalid_xml = <<-XML invalid_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
</XRD> </XRD>

View file

@ -2,7 +2,7 @@
module DiasporaFederation module DiasporaFederation
describe Discovery::XrdDocument do describe Discovery::XrdDocument do
let(:xml) { <<-XML } let(:xml) { <<~XML }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Expires>2010-01-30T09:30:00Z</Expires> <Expires>2010-01-30T09:30:00Z</Expires>
@ -17,7 +17,7 @@ module DiasporaFederation
</XRD> </XRD>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"subject": "http://blog.example.com/article/id/314", "subject": "http://blog.example.com/article/id/314",
"expires": "2010-01-30T09:30:00Z", "expires": "2010-01-30T09:30:00Z",

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::AccountDeletion do describe Entities::AccountDeletion do
let(:data) { Fabricate.attributes_for(:account_deletion_entity) } let(:data) { Fabricate.attributes_for(:account_deletion_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<account_deletion> <account_deletion>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
</account_deletion> </account_deletion>

View file

@ -107,7 +107,7 @@ module DiasporaFederation
} }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<account_migration> <account_migration>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<profile> <profile>
@ -146,7 +146,7 @@ XML
} }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<account_migration> <account_migration>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<profile> <profile>
@ -184,7 +184,7 @@ XML
} }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<account_migration> <account_migration>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<profile> <profile>

View file

@ -14,7 +14,7 @@ module DiasporaFederation
).tap {|hash| add_signatures(hash) } ).tap {|hash| add_signatures(hash) }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<comment> <comment>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -27,7 +27,7 @@ module DiasporaFederation
</comment> </comment>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "comment", "entity_type": "comment",
"entity_data": { "entity_data": {

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Contact do describe Entities::Contact do
let(:data) { Fabricate.attributes_for(:contact_entity) } let(:data) { Fabricate.attributes_for(:contact_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<contact> <contact>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<recipient>#{data[:recipient]}</recipient> <recipient>#{data[:recipient]}</recipient>

View file

@ -29,7 +29,7 @@ module DiasporaFederation
) )
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<conversation> <conversation>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{parent.guid}</guid> <guid>#{parent.guid}</guid>
@ -48,7 +48,7 @@ XML
context "default values" do context "default values" do
it "allows no nested messages" do it "allows no nested messages" do
minimal_xml = <<-XML minimal_xml = <<~XML
<conversation> <conversation>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{parent.guid}</guid> <guid>#{parent.guid}</guid>

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Embed do describe Entities::Embed do
let(:data) { Fabricate.attributes_for(:embed_entity) } let(:data) { Fabricate.attributes_for(:embed_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<embed> <embed>
<url>#{data[:url]}</url> <url>#{data[:url]}</url>
<title>#{data[:title]}</title> <title>#{data[:title]}</title>
@ -13,7 +13,7 @@ module DiasporaFederation
</embed> </embed>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "embed", "entity_type": "embed",
"entity_data": { "entity_data": {

View file

@ -13,7 +13,7 @@ module DiasporaFederation
).tap {|hash| add_signatures(hash) } ).tap {|hash| add_signatures(hash) }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<event_participation> <event_participation>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>

View file

@ -7,7 +7,7 @@ module DiasporaFederation
Fabricate.attributes_for(:event_entity).merge(author: alice.diaspora_id, location: location) Fabricate.attributes_for(:event_entity).merge(author: alice.diaspora_id, location: location)
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<event> <event>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -34,7 +34,7 @@ XML
context "default values" do context "default values" do
it "uses default values" do it "uses default values" do
minimal_xml = <<-XML minimal_xml = <<~XML
<event> <event>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>

View file

@ -14,7 +14,7 @@ module DiasporaFederation
).tap {|hash| add_signatures(hash) } ).tap {|hash| add_signatures(hash) }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<like> <like>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -26,7 +26,7 @@ module DiasporaFederation
</like> </like>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "like", "entity_type": "like",
"entity_data": { "entity_data": {
@ -61,7 +61,7 @@ JSON
context "invalid XML" do context "invalid XML" do
it "raises a ValidationError if the parent_type is missing" do it "raises a ValidationError if the parent_type is missing" do
broken_xml = <<-XML broken_xml = <<~XML
<like> <like>
<parent_guid>#{parent.guid}</parent_guid> <parent_guid>#{parent.guid}</parent_guid>
</like> </like>
@ -73,7 +73,7 @@ XML
end end
it "raises a ValidationError if the parent_guid is missing" do it "raises a ValidationError if the parent_guid is missing" do
broken_xml = <<-XML broken_xml = <<~XML
<like> <like>
<target_type>#{parent.entity_type}</target_type> <target_type>#{parent.entity_type}</target_type>
</like> </like>

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Location do describe Entities::Location do
let(:data) { Fabricate.attributes_for(:location_entity) } let(:data) { Fabricate.attributes_for(:location_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<location> <location>
<address>#{data[:address]}</address> <address>#{data[:address]}</address>
<lat>#{data[:lat]}</lat> <lat>#{data[:lat]}</lat>
@ -12,7 +12,7 @@ module DiasporaFederation
</location> </location>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "location", "entity_type": "location",
"entity_data": { "entity_data": {

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Message do describe Entities::Message do
let(:data) { Fabricate.attributes_for(:message_entity, author: alice.diaspora_id) } let(:data) { Fabricate.attributes_for(:message_entity, author: alice.diaspora_id) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<message> <message>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>

View file

@ -12,7 +12,7 @@ module DiasporaFederation
) )
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<participation> <participation>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -21,7 +21,7 @@ module DiasporaFederation
</participation> </participation>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "participation", "entity_type": "participation",
"entity_data": { "entity_data": {

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Person do describe Entities::Person do
let(:data) { Fabricate.attributes_for(:person_entity) } let(:data) { Fabricate.attributes_for(:person_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<person> <person>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Photo do describe Entities::Photo do
let(:data) { Fabricate.attributes_for(:photo_entity) } let(:data) { Fabricate.attributes_for(:photo_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<photo> <photo>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
@ -20,7 +20,7 @@ module DiasporaFederation
</photo> </photo>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "photo", "entity_type": "photo",
"entity_data": { "entity_data": {
@ -49,7 +49,7 @@ JSON
context "default values" do context "default values" do
it "uses default values" do it "uses default values" do
minimal_xml = <<-XML minimal_xml = <<~XML
<photo> <photo>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>

View file

@ -4,14 +4,14 @@ module DiasporaFederation
describe Entities::PollAnswer do describe Entities::PollAnswer do
let(:data) { Fabricate.attributes_for(:poll_answer_entity) } let(:data) { Fabricate.attributes_for(:poll_answer_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<poll_answer> <poll_answer>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<answer>#{data[:answer]}</answer> <answer>#{data[:answer]}</answer>
</poll_answer> </poll_answer>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "poll_answer", "entity_type": "poll_answer",
"entity_data": { "entity_data": {

View file

@ -13,7 +13,7 @@ module DiasporaFederation
).tap {|hash| add_signatures(hash) } ).tap {|hash| add_signatures(hash) }
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<poll_participation> <poll_participation>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -24,7 +24,7 @@ module DiasporaFederation
</poll_participation> </poll_participation>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "poll_participation", "entity_type": "poll_participation",
"entity_data": { "entity_data": {

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Poll do describe Entities::Poll do
let(:data) { Fabricate.attributes_for(:poll_entity) } let(:data) { Fabricate.attributes_for(:poll_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<poll> <poll>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<question>#{data[:question]}</question> <question>#{data[:question]}</question>
@ -12,7 +12,7 @@ module DiasporaFederation
</poll> </poll>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "poll", "entity_type": "poll",
"entity_data": { "entity_data": {

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Profile do describe Entities::Profile do
let(:data) { Fabricate.attributes_for(:profile_entity) } let(:data) { Fabricate.attributes_for(:profile_entity) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<profile> <profile>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<edited_at>#{data[:edited_at].utc.iso8601}</edited_at> <edited_at>#{data[:edited_at].utc.iso8601}</edited_at>
@ -24,7 +24,7 @@ module DiasporaFederation
</profile> </profile>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "profile", "entity_type": "profile",
"entity_data": { "entity_data": {
@ -57,7 +57,7 @@ JSON
context "default values" do context "default values" do
it "uses default values" do it "uses default values" do
minimal_xml = <<-XML minimal_xml = <<~XML
<profile> <profile>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
</profile> </profile>

View file

@ -12,7 +12,7 @@ module DiasporaFederation
} }
let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} } let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<relayable_retraction> <relayable_retraction>
<parent_author_signature/> <parent_author_signature/>
<target_guid>#{data[:target_guid]}</target_guid> <target_guid>#{data[:target_guid]}</target_guid>

View file

@ -122,7 +122,7 @@ module DiasporaFederation
end end
describe "#to_xml" do describe "#to_xml" do
let(:expected_xml) { <<-XML } let(:expected_xml) { <<~XML }
<some_relayable> <some_relayable>
<author>#{author}</author> <author>#{author}</author>
<guid>#{guid}</guid> <guid>#{guid}</guid>
@ -161,7 +161,7 @@ XML
end end
it "adds nil properties to xml when needed for signature_order" do it "adds nil properties to xml when needed for signature_order" do
expected_xml = <<-XML expected_xml = <<~XML
<some_relayable> <some_relayable>
<author>#{author}</author> <author>#{author}</author>
<guid>#{guid}</guid> <guid>#{guid}</guid>
@ -182,7 +182,7 @@ XML
end end
it "does not add nil properties to xml when not needed for signature_order" do it "does not add nil properties to xml when not needed for signature_order" do
expected_xml = <<-XML expected_xml = <<~XML
<some_relayable> <some_relayable>
<author>#{author}</author> <author>#{author}</author>
<guid>#{guid}</guid> <guid>#{guid}</guid>
@ -283,7 +283,7 @@ XML
end end
it "adds 'false' booleans" do it "adds 'false' booleans" do
expected_xml = <<-XML expected_xml = <<~XML
<test_relayable_with_boolean> <test_relayable_with_boolean>
<author>#{author}</author> <author>#{author}</author>
<guid>#{guid}</guid> <guid>#{guid}</guid>
@ -308,7 +308,7 @@ XML
end end
let(:new_signature_data) { "#{author};#{guid};#{parent_guid};#{new_property};#{property}" } let(:new_signature_data) { "#{author};#{guid};#{parent_guid};#{new_property};#{property}" }
let(:new_xml) { <<-XML } let(:new_xml) { <<~XML }
<some_relayable> <some_relayable>
<diaspora_handle>#{author}</diaspora_handle> <diaspora_handle>#{author}</diaspora_handle>
<guid>#{guid}</guid> <guid>#{guid}</guid>
@ -352,7 +352,7 @@ XML
context "parse invalid XML" do context "parse invalid XML" do
it "raises a ValidationError if the parent_guid is missing" do it "raises a ValidationError if the parent_guid is missing" do
broken_xml = <<-XML broken_xml = <<~XML
<some_relayable> <some_relayable>
</some_relayable> </some_relayable>
XML XML
@ -363,7 +363,7 @@ XML
end end
it "adds the guid to the error message if available" do it "adds the guid to the error message if available" do
broken_xml = <<-XML broken_xml = <<~XML
<some_relayable> <some_relayable>
<guid>#{guid}</guid> <guid>#{guid}</guid>
</some_relayable> </some_relayable>
@ -375,7 +375,7 @@ XML
end end
it "adds the author to the error message if available" do it "adds the author to the error message if available" do
broken_xml = <<-XML broken_xml = <<~XML
<some_relayable> <some_relayable>
<author>#{author}</author> <author>#{author}</author>
</some_relayable> </some_relayable>

View file

@ -4,7 +4,7 @@ module DiasporaFederation
describe Entities::Request do describe Entities::Request do
let(:data) { {author: Fabricate.sequence(:diaspora_id), recipient: Fabricate.sequence(:diaspora_id)} } let(:data) { {author: Fabricate.sequence(:diaspora_id), recipient: Fabricate.sequence(:diaspora_id)} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<request> <request>
<sender_handle>#{data[:author]}</sender_handle> <sender_handle>#{data[:author]}</sender_handle>
<recipient_handle>#{data[:recipient]}</recipient_handle> <recipient_handle>#{data[:recipient]}</recipient_handle>

View file

@ -5,7 +5,7 @@ module DiasporaFederation
let(:root) { Fabricate(:post, author: bob) } let(:root) { Fabricate(:post, author: bob) }
let(:data) { Fabricate.attributes_for(:reshare_entity, root_guid: root.guid, root_author: bob.diaspora_id) } let(:data) { Fabricate.attributes_for(:reshare_entity, root_guid: root.guid, root_author: bob.diaspora_id) }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<reshare> <reshare>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -15,7 +15,7 @@ module DiasporaFederation
</reshare> </reshare>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "reshare", "entity_type": "reshare",
"entity_data": { "entity_data": {

View file

@ -13,7 +13,7 @@ module DiasporaFederation
) )
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<retraction> <retraction>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<target_guid>#{data[:target_guid]}</target_guid> <target_guid>#{data[:target_guid]}</target_guid>

View file

@ -6,7 +6,7 @@ module DiasporaFederation
let(:target_entity) { Fabricate(:related_entity, author: alice.diaspora_id) } let(:target_entity) { Fabricate(:related_entity, author: alice.diaspora_id) }
let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} } let(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<signed_retraction> <signed_retraction>
<target_guid>#{data[:target_guid]}</target_guid> <target_guid>#{data[:target_guid]}</target_guid>
<target_type>#{data[:target_type]}</target_type> <target_type>#{data[:target_type]}</target_type>

View file

@ -17,7 +17,7 @@ module DiasporaFederation
) )
} }
let(:xml) { <<-XML } let(:xml) { <<~XML }
<status_message> <status_message>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -60,7 +60,7 @@ module DiasporaFederation
</status_message> </status_message>
XML XML
let(:json) { <<-JSON } let(:json) { <<~JSON }
{ {
"entity_type": "status_message", "entity_type": "status_message",
"entity_data": { "entity_data": {
@ -127,7 +127,7 @@ JSON
context "default values" do context "default values" do
it "uses default values" do it "uses default values" do
minimal_xml = <<-XML minimal_xml = <<~XML
<status_message> <status_message>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>

View file

@ -204,7 +204,7 @@ module DiasporaFederation
test2: "qwer", test2: "qwer",
test3: true test3: true
) )
Entities::TestDefaultEntity.from_xml(Nokogiri::XML(<<-XML).root) Entities::TestDefaultEntity.from_xml(Nokogiri::XML(<<~XML).root)
<test_default_entity> <test_default_entity>
<test1>asdf</test1> <test1>asdf</test1>
<test2>qwer</qwer2> <test2>qwer</qwer2>
@ -286,7 +286,7 @@ XML
describe ".from_json" do describe ".from_json" do
it "parses entity properties from the input JSON data" do it "parses entity properties from the input JSON data" do
now = change_time(Time.now.utc) now = change_time(Time.now.utc)
entity_data = <<-JSON entity_data = <<~JSON
{ {
"entity_type": "test_complex_entity", "entity_type": "test_complex_entity",
"entity_data": { "entity_data": {
@ -513,7 +513,7 @@ JSON
end end
it "handles empty xml-element for nested entities" do it "handles empty xml-element for nested entities" do
xml = <<-XML xml = <<~XML
<test_nested_entity> <test_nested_entity>
<asdf>FDSA</asdf> <asdf>FDSA</asdf>
<test_entity/> <test_entity/>

View file

@ -8,7 +8,7 @@ module DiasporaFederation
it "raises error when the entity class doesn't match the entity_type property" do it "raises error when the entity class doesn't match the entity_type property" do
expect { expect {
json_parser.parse(JSON.parse(<<-JSON json_parser.parse(JSON.parse(<<~JSON
{ {
"entity_type": "unknown_entity", "entity_type": "unknown_entity",
"entity_data": {} "entity_data": {}
@ -29,7 +29,7 @@ JSON
it "returns a hash for the correct JSON input" do it "returns a hash for the correct JSON input" do
now = change_time(Time.now.utc) now = change_time(Time.now.utc)
json = <<-JSON json = <<~JSON
{ {
"entity_type": "test_complex_entity", "entity_type": "test_complex_entity",
"entity_data": { "entity_data": {
@ -77,7 +77,7 @@ JSON
end end
it "doesn't drop extra properties" do it "doesn't drop extra properties" do
json = <<-JSON.strip json = <<~JSON.strip
{ {
"entity_type": "test_default_entity", "entity_type": "test_default_entity",
"entity_data": { "entity_data": {

View file

@ -10,7 +10,7 @@ module DiasporaFederation
'{"entity_type": "some_relayable", "entity_data": {}}' '{"entity_type": "some_relayable", "entity_data": {}}'
it "returns property order as a second argument" do it "returns property order as a second argument" do
json = JSON.parse <<-JSON json = JSON.parse <<~JSON
{ {
"entity_type": "some_relayable", "entity_type": "some_relayable",
"property_order": ["property", "guid", "author"], "property_order": ["property", "guid", "author"],

View file

@ -6,7 +6,7 @@ module DiasporaFederation
let(:entity_class) { Entities::SomeRelayable } let(:entity_class) { Entities::SomeRelayable }
let(:xml_parser) { Parsers::RelayableXmlParser.new(entity_class) } let(:xml_parser) { Parsers::RelayableXmlParser.new(entity_class) }
it "passes order of the XML elements as a second argument in the returned list" do it "passes order of the XML elements as a second argument in the returned list" do
xml_object = Nokogiri::XML(<<-XML).root xml_object = Nokogiri::XML(<<~XML).root
<some_relayable> <some_relayable>
<guid>im a guid</guid> <guid>im a guid</guid>
<property>value</property> <property>value</property>

View file

@ -13,7 +13,7 @@ module DiasporaFederation
end end
it "raises an error when the entity class doesn't match the root node" do it "raises an error when the entity class doesn't match the root node" do
xml = <<-XML xml = <<~XML
<unknown_entity> <unknown_entity>
<test>asdf</test> <test>asdf</test>
</unknown_entity> </unknown_entity>
@ -34,7 +34,7 @@ XML
end end
it "uses xml_name for parsing" do it "uses xml_name for parsing" do
xml = <<-XML.strip xml = <<~XML.strip
<test_entity_with_xml_name> <test_entity_with_xml_name>
<test>asdf</test> <test>asdf</test>
<asdf>qwer</asdf> <asdf>qwer</asdf>
@ -48,7 +48,7 @@ XML
end end
it "allows name for parsing even when property has a xml_name" do it "allows name for parsing even when property has a xml_name" do
xml = <<-XML.strip xml = <<~XML.strip
<test_entity_with_xml_name> <test_entity_with_xml_name>
<test>asdf</test> <test>asdf</test>
<qwer>qwer</qwer> <qwer>qwer</qwer>
@ -62,7 +62,7 @@ XML
end end
it "parses the string to the correct type" do it "parses the string to the correct type" do
xml = <<-XML.strip xml = <<~XML.strip
<test_default_entity> <test_default_entity>
<test1>asdf</test1> <test1>asdf</test1>
<test2>qwer</qwer2> <test2>qwer</qwer2>
@ -78,7 +78,7 @@ XML
end end
it "parses boolean fields with false value" do it "parses boolean fields with false value" do
xml = <<-XML.strip xml = <<~XML.strip
<test_entity_with_boolean> <test_entity_with_boolean>
<test>false</test> <test>false</test>
</test_entity_with_boolean> </test_entity_with_boolean>
@ -90,7 +90,7 @@ XML
it "parses boolean fields with a randomly matching pattern as nil" do it "parses boolean fields with a randomly matching pattern as nil" do
%w[ttFFFtt yesFFDSFSDy noDFDSFFDFn fXf LLyes].each do |weird_value| %w[ttFFFtt yesFFDSFSDy noDFDSFFDFn fXf LLyes].each do |weird_value|
xml = <<-XML.strip xml = <<~XML.strip
<test_entity_with_boolean> <test_entity_with_boolean>
<test>#{weird_value}</test> <test>#{weird_value}</test>
</test_entity_with_boolean> </test_entity_with_boolean>
@ -105,7 +105,7 @@ XML
it "parses integer fields with a randomly matching pattern as nil" do it "parses integer fields with a randomly matching pattern as nil" do
%w[1,2,3 foobar two].each do |weird_value| %w[1,2,3 foobar two].each do |weird_value|
xml = <<-XML.strip xml = <<~XML.strip
<test_entity_with_integer> <test_entity_with_integer>
<test>#{weird_value}</test> <test>#{weird_value}</test>
</test_entity_with_integer> </test_entity_with_integer>
@ -120,7 +120,7 @@ XML
it "parses timestamp fields with a randomly matching pattern as nil" do it "parses timestamp fields with a randomly matching pattern as nil" do
%w[foobar yesterday now 1.2.foo].each do |weird_value| %w[foobar yesterday now 1.2.foo].each do |weird_value|
xml = <<-XML.strip xml = <<~XML.strip
<test_entity_with_timestamp> <test_entity_with_timestamp>
<test>#{weird_value}</test> <test>#{weird_value}</test>
</test_entity_with_timestamp> </test_entity_with_timestamp>
@ -154,7 +154,7 @@ XML
end end
it "doesn't drop extra properties" do it "doesn't drop extra properties" do
xml = <<-XML.strip xml = <<~XML.strip
<test_default_entity> <test_default_entity>
<test1>asdf</test1> <test1>asdf</test1>
<test2>qwer</test2> <test2>qwer</test2>

View file

@ -27,7 +27,7 @@ module DiasporaFederation
end end
it "verifies the existence of 'encrypted_header'" do it "verifies the existence of 'encrypted_header'" do
faulty_xml = <<XML faulty_xml = <<~XML
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env"> <diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
</diaspora> </diaspora>
XML XML
@ -37,7 +37,7 @@ XML
end end
it "verifies the existence of a magic envelope" do it "verifies the existence of a magic envelope" do
faulty_xml = <<XML faulty_xml = <<~XML
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env"> <diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
<encrypted_header/> <encrypted_header/>
</diaspora> </diaspora>

View file

@ -26,7 +26,7 @@ module DiasporaFederation
end end
it "verifies the existence of an author_id" do it "verifies the existence of an author_id" do
faulty_xml = <<XML faulty_xml = <<~XML
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env"> <diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
<header/> <header/>
</diaspora> </diaspora>
@ -37,7 +37,7 @@ XML
end end
it "verifies the existence of a magic envelope" do it "verifies the existence of a magic envelope" do
faulty_xml = <<-XML faulty_xml = <<~XML
<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env"> <diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env">
<header> <header>
<author_id>#{sender}</author_id> <author_id>#{sender}</author_id>

View file

@ -3,7 +3,7 @@
module DiasporaFederation module DiasporaFederation
describe Salmon::XmlPayload do describe Salmon::XmlPayload do
let(:entity) { Entities::TestEntity.new(test: "asdf") } let(:entity) { Entities::TestEntity.new(test: "asdf") }
let(:entity_xml) { <<-XML.strip } let(:entity_xml) { <<~XML.strip }
<XML> <XML>
<post> <post>
<test_entity> <test_entity>
@ -43,7 +43,7 @@ XML
end end
it "allows unwrapped entities" do it "allows unwrapped entities" do
xml = <<-XML xml = <<~XML
<test_entity> <test_entity>
<test>asdf</test> <test>asdf</test>
</test_entity> </test_entity>