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:
- "lib/diaspora_federation/discovery/xrd_document.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
describe Entities::Relayable do
let(:author_serialized_key) { <<-KEY }
let(:author_serialized_key) { <<~KEY }
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh
btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr
@ -27,7 +27,7 @@ KEY
# g6zpg1zxGahpmxwqFQIDAQAB
# -----END PUBLIC KEY-----
let(:parent_serialized_key) { <<-KEY }
let(:parent_serialized_key) { <<~KEY }
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/
F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx
@ -65,7 +65,7 @@ KEY
)
}
let(:legacy_format_comment_xml_alice) { <<-XML }
let(:legacy_format_comment_xml_alice) { <<~XML }
<XML>
<post>
<comment>
@ -79,7 +79,7 @@ KEY
</post>
</XML>
XML
let(:new_format_comment_xml_alice) { <<-XML }
let(:new_format_comment_xml_alice) { <<~XML }
<comment>
<author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -89,7 +89,7 @@ XML
<parent_author_signature/>
</comment>
XML
let(:new_data_comment_xml_alice) { <<-XML }
let(:new_data_comment_xml_alice) { <<~XML }
<comment>
<author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -101,7 +101,7 @@ XML
</comment>
XML
let(:legacy_format_comment_xml_bob) { <<-XML }
let(:legacy_format_comment_xml_bob) { <<~XML }
<XML>
<post>
<comment>
@ -115,7 +115,7 @@ XML
</post>
</XML>
XML
let(:legacy_order_new_format_comment_xml_bob) { <<-XML }
let(:legacy_order_new_format_comment_xml_bob) { <<~XML }
<comment>
<guid>e21589b0b41101333b870f77ba60fa73</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>
</comment>
XML
let(:new_order_legacy_format_comment_xml_bob) { <<-XML }
let(:new_order_legacy_format_comment_xml_bob) { <<~XML }
<XML>
<post>
<comment>
@ -139,7 +139,7 @@ XML
</post>
</XML>
XML
let(:new_format_comment_xml_bob) { <<-XML }
let(:new_format_comment_xml_bob) { <<~XML }
<comment>
<author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -149,7 +149,7 @@ XML
<parent_author_signature>hWsagsczmZD6d36d6MFdTt3hKAdnRtupSIU6464G2kkMJ+WlExxMgbF6kWR+jVCBTeKipWCYK3Arnj0YkuIZM9d14bJGVMTsW/ZzNfJ69bXZhsyawI8dPnZnLVydo+hU/XmGJBEuh2TOj9Emq6/HCYiWzPTF5qhYAtyJ1oxJ4Yk=</parent_author_signature>
</comment>
XML
let(:legacy_format_new_data_comment_xml_bob) { <<-XML }
let(:legacy_format_new_data_comment_xml_bob) { <<~XML }
<XML>
<post>
<comment>
@ -164,7 +164,7 @@ XML
</post>
</XML>
XML
let(:new_data_comment_xml_bob) { <<-XML }
let(:new_data_comment_xml_bob) { <<~XML }
<comment>
<author>alice@pod-a.org</author>
<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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@ -136,7 +136,7 @@ HTML
end
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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@ -261,7 +261,7 @@ HTML
end
it "fails if the document is incomplete" do
invalid_html = <<-HTML
invalid_html = <<~HTML
<div id="content">
<span class="fn">#{person.full_name}</span>
</div>

View file

@ -3,7 +3,7 @@
module DiasporaFederation
describe Discovery::HostMeta do
let(:base_url) { "https://pod.example.tld/" }
let(:xml) { <<-XML }
let(:xml) { <<~XML }
<?xml version="1.0" encoding="UTF-8"?>
<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}"/>
@ -42,7 +42,7 @@ XML
end
it "also reads old-style XML" do
historic_xml = <<-XML
historic_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
@ -59,7 +59,7 @@ XML
end
it "also reads friendica/redmatrix XML" do
friendica_redmatrix_xml = <<-XML
friendica_redmatrix_xml = <<~XML
<?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:hm='http://host-meta.net/xrd/1.0'>
@ -77,7 +77,7 @@ XML
end
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"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
</XRD>
@ -86,7 +86,7 @@ XML
end
it "fails if the document contains a malformed webfinger url" do
invalid_xml = <<XML
invalid_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<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"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>#{acct}</Subject>
@ -32,7 +32,7 @@ module DiasporaFederation
</XRD>
XML
let(:minimal_xml) { <<-XML }
let(:minimal_xml) { <<~XML }
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>#{acct}</Subject>
@ -41,7 +41,7 @@ XML
</XRD>
XML
let(:json) { <<-JSON }
let(:json) { <<~JSON }
{
"subject": "#{acct}",
"aliases": [
@ -80,7 +80,7 @@ XML
}
JSON
let(:minimal_json) { <<-JSON }
let(:minimal_json) { <<~JSON }
{
"subject": "#{acct}",
"links": [
@ -132,7 +132,7 @@ JSON
end
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"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>#{acct}</Subject>
@ -164,7 +164,7 @@ XML
end
it "creates JSON document with additional data" do
json_with_additional_data = <<-JSON
json_with_additional_data = <<~JSON
{
"subject": "#{acct}",
"aliases": [
@ -251,7 +251,7 @@ JSON
end
it "reads friendica XML (two aliases, first with acct)" do
friendica_xml = <<-XML
friendica_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
@ -308,7 +308,7 @@ JSON
end
it "reads redmatrix XML (no alias)" do
redmatrix_xml = <<-XML
redmatrix_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
@ -349,7 +349,7 @@ JSON
end
it "fails if the document is empty" do
invalid_xml = <<-XML
invalid_xml = <<~XML
<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
</XRD>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@ module DiasporaFederation
)
}
let(:xml) { <<-XML }
let(:xml) { <<~XML }
<retraction>
<author>#{data[:author]}</author>
<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(:data) { {author: alice.diaspora_id, target_guid: target.guid, target_type: target.entity_type} }
let(:xml) { <<-XML }
let(:xml) { <<~XML }
<signed_retraction>
<target_guid>#{data[:target_guid]}</target_guid>
<target_type>#{data[:target_type]}</target_type>

View file

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

View file

@ -204,7 +204,7 @@ module DiasporaFederation
test2: "qwer",
test3: true
)
Entities::TestDefaultEntity.from_xml(Nokogiri::XML(<<-XML).root)
Entities::TestDefaultEntity.from_xml(Nokogiri::XML(<<~XML).root)
<test_default_entity>
<test1>asdf</test1>
<test2>qwer</qwer2>
@ -286,7 +286,7 @@ XML
describe ".from_json" do
it "parses entity properties from the input JSON data" do
now = change_time(Time.now.utc)
entity_data = <<-JSON
entity_data = <<~JSON
{
"entity_type": "test_complex_entity",
"entity_data": {
@ -513,7 +513,7 @@ JSON
end
it "handles empty xml-element for nested entities" do
xml = <<-XML
xml = <<~XML
<test_nested_entity>
<asdf>FDSA</asdf>
<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
expect {
json_parser.parse(JSON.parse(<<-JSON
json_parser.parse(JSON.parse(<<~JSON
{
"entity_type": "unknown_entity",
"entity_data": {}
@ -29,7 +29,7 @@ JSON
it "returns a hash for the correct JSON input" do
now = change_time(Time.now.utc)
json = <<-JSON
json = <<~JSON
{
"entity_type": "test_complex_entity",
"entity_data": {
@ -77,7 +77,7 @@ JSON
end
it "doesn't drop extra properties" do
json = <<-JSON.strip
json = <<~JSON.strip
{
"entity_type": "test_default_entity",
"entity_data": {

View file

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

View file

@ -6,7 +6,7 @@ module DiasporaFederation
let(:entity_class) { Entities::SomeRelayable }
let(:xml_parser) { Parsers::RelayableXmlParser.new(entity_class) }
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>
<guid>im a guid</guid>
<property>value</property>

View file

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

View file

@ -27,7 +27,7 @@ module DiasporaFederation
end
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>
XML
@ -37,7 +37,7 @@ XML
end
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">
<encrypted_header/>
</diaspora>

View file

@ -26,7 +26,7 @@ module DiasporaFederation
end
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">
<header/>
</diaspora>
@ -37,7 +37,7 @@ XML
end
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">
<header>
<author_id>#{sender}</author_id>

View file

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