update string blocks for new rubocop

This commit is contained in:
Benjamin Neff 2016-07-14 01:21:40 +02:00
parent be7264b604
commit c0e798c55e
27 changed files with 76 additions and 136 deletions

View file

@ -1,7 +1,6 @@
module DiasporaFederation module DiasporaFederation
describe Entities::Relayable do describe Entities::Relayable do
let(:author_serialized_key) { let(:author_serialized_key) { <<-KEY }
<<-KEY
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh MIICXgIBAAKBgQCxTbMp+M5sCUDVi9k1wMxedSwyLQcjBKQa0Qs6Qpnflz0k90hh
btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr btau0cy9jTK6S3CK2GhERXD6EecDlhZCbnSI9Bwmco5j6NbGPN5ai9tWgiBZzaEr
@ -18,7 +17,6 @@ nRcJ3dILfGs4FFN630MBAkEA3zMOyNTeNdHrVhZc5b0qw2T6FUJGieDpOWLsff4w
84yW10oS2CCmqEhbfh4Wu22amglytrATwD9hDzsTNAt8Mg== 84yW10oS2CCmqEhbfh4Wu22amglytrATwD9hDzsTNAt8Mg==
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
KEY KEY
}
let(:author_key) { OpenSSL::PKey::RSA.new(author_serialized_key) } let(:author_key) { OpenSSL::PKey::RSA.new(author_serialized_key) }
# -----BEGIN PUBLIC KEY----- # -----BEGIN PUBLIC KEY-----
# MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxTbMp+M5sCUDVi9k1wMxedSwy # MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxTbMp+M5sCUDVi9k1wMxedSwy
@ -27,8 +25,7 @@ KEY
# g6zpg1zxGahpmxwqFQIDAQAB # g6zpg1zxGahpmxwqFQIDAQAB
# -----END PUBLIC KEY----- # -----END PUBLIC KEY-----
let(:parent_serialized_key) { let(:parent_serialized_key) { <<-KEY }
<<-KEY
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/ MIICXgIBAAKBgQDrOvW1UArKoUOg54XWXcTD3jU0zKG3Pm9IeaEzfQtApogQ3+M/
F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx F9nz0i3q8UhTDEPBQ3hMbqJ/4qfY+wFulxMR58DbqxFx9QcNZISUd0CPx/fJOYMx
@ -45,7 +42,6 @@ yq359XWooo3N7kmduEKhAkEAppzKLuVtX1XPL4VZBex/M2ewngjkSg964BvxIBwv
bFzeSqlMpnbEoOJ9hhx6CsP6Y7V19DRRXi0XgwcAjHLz8g== bFzeSqlMpnbEoOJ9hhx6CsP6Y7V19DRRXi0XgwcAjHLz8g==
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
KEY KEY
}
let(:parent_key) { OpenSSL::PKey::RSA.new(parent_serialized_key) } let(:parent_key) { OpenSSL::PKey::RSA.new(parent_serialized_key) }
# -----BEGIN PUBLIC KEY----- # -----BEGIN PUBLIC KEY-----
# MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrOvW1UArKoUOg54XWXcTD3jU0 # MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrOvW1UArKoUOg54XWXcTD3jU0
@ -67,8 +63,7 @@ KEY
) )
} }
let(:legacy_comment_xml_alice) { let(:legacy_comment_xml_alice) { <<-XML }
<<-XML
<XML> <XML>
<post> <post>
<comment> <comment>
@ -82,9 +77,7 @@ KEY
</post> </post>
</XML> </XML>
XML XML
} let(:new_signature_comment_xml_alice) { <<-XML }
let(:new_signature_comment_xml_alice) {
<<-XML
<comment> <comment>
<author>alice@pod-a.org</author> <author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -94,9 +87,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>
@ -107,10 +98,8 @@ XML
<parent_author_signature/> <parent_author_signature/>
</comment> </comment>
XML XML
}
let(:legacy_comment_xml_bob) { let(:legacy_comment_xml_bob) { <<-XML }
<<-XML
<XML> <XML>
<post> <post>
<comment> <comment>
@ -124,9 +113,7 @@ XML
</post> </post>
</XML> </XML>
XML XML
} let(:legacy_new_signature_comment_xml_bob) { <<-XML }
let(:legacy_new_signature_comment_xml_bob) {
<<-XML
<XML> <XML>
<post> <post>
<comment> <comment>
@ -140,9 +127,7 @@ XML
</post> </post>
</XML> </XML>
XML XML
} let(:new_signature_comment_xml_bob) { <<-XML }
let(:new_signature_comment_xml_bob) {
<<-XML
<comment> <comment>
<author>alice@pod-a.org</author> <author>alice@pod-a.org</author>
<guid>e21589b0b41101333b870f77ba60fa73</guid> <guid>e21589b0b41101333b870f77ba60fa73</guid>
@ -152,9 +137,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_new_data_comment_xml_bob) { <<-XML }
let(:legacy_new_data_comment_xml_bob) {
<<-XML
<XML> <XML>
<post> <post>
<comment> <comment>
@ -169,9 +152,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>
@ -182,7 +163,6 @@ XML
<parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature> <parent_author_signature>NxXuEUVeXwUMR77osIbaNlp2oB3bpl8rBEFgQoO6cnoN5ewDbiGADK0x6EhcmJptjwhGVcZiNJNpq7k3/pjJtKaH++3ToCAtcuZoIKwPDsneLnjPhVjE2GXM1TiZKwoHrq41qSp/8Vl5UPbtC6sPiOzIvPKaILXUG8XCiVWuB0M=</parent_author_signature>
</comment> </comment>
XML XML
}
# this was used to create the XMLs above # this was used to create the XMLs above
context "test-data creation" do context "test-data creation" do

View file

@ -21,8 +21,7 @@ module DiasporaFederation
} }
} }
let(:html) { let(:html) { <<-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>
@ -106,7 +105,7 @@ module DiasporaFederation
</body> </body>
</html> </html>
HTML HTML
}
let(:string) { "HCard:#{data[:guid]}" } let(:string) { "HCard:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -1,14 +1,12 @@
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) { let(:xml) { <<-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={uri}"/> <Link rel="lrdd" type="application/xrd+xml" template="#{base_url}webfinger?q={uri}"/>
</XRD> </XRD>
XML XML
}
it "must not create blank instances" do it "must not create blank instances" do
expect { Discovery::HostMeta.new }.to raise_error NoMethodError expect { Discovery::HostMeta.new }.to raise_error NoMethodError

View file

@ -19,8 +19,7 @@ module DiasporaFederation
} }
} }
let(:xml) { let(:xml) { <<-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>
@ -35,7 +34,7 @@ module DiasporaFederation
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}"/> <Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}"/>
</XRD> </XRD>
XML XML
}
let(:string) { "WebFinger:#{data[:acct_uri]}" } let(:string) { "WebFinger:#{data[:acct_uri]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -1,7 +1,6 @@
module DiasporaFederation module DiasporaFederation
describe Discovery::XrdDocument do describe Discovery::XrdDocument do
let(:xml) { let(:xml) { <<-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>
@ -15,7 +14,6 @@ module DiasporaFederation
<Link rel="copyright" template="http://example.com/copyright?id={uri}"/> <Link rel="copyright" template="http://example.com/copyright?id={uri}"/>
</XRD> </XRD>
XML XML
}
let(:data) { let(:data) {
{ {

View file

@ -2,13 +2,12 @@ module DiasporaFederation
describe Entities::AccountDeletion do describe Entities::AccountDeletion do
let(:data) { FactoryGirl.attributes_for(:account_deletion_entity) } let(:data) { FactoryGirl.attributes_for(:account_deletion_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<account_deletion> <account_deletion>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
</account_deletion> </account_deletion>
XML XML
}
let(:string) { "AccountDeletion:#{data[:author]}" } let(:string) { "AccountDeletion:#{data[:author]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -7,8 +7,7 @@ module DiasporaFederation
.send(:xml_elements).merge(created_at: Time.now.utc, parent: parent_entity) .send(:xml_elements).merge(created_at: Time.now.utc, parent: parent_entity)
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<comment> <comment>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid> <parent_guid>#{parent.guid}</parent_guid>
@ -18,7 +17,7 @@ module DiasporaFederation
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</comment> </comment>
XML XML
}
let(:string) { "Comment:#{data[:guid]}:#{parent.guid}" } let(:string) { "Comment:#{data[:guid]}:#{parent.guid}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -2,8 +2,7 @@ module DiasporaFederation
describe Entities::Contact do describe Entities::Contact do
let(:data) { FactoryGirl.attributes_for(:contact_entity) } let(:data) { FactoryGirl.attributes_for(:contact_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<contact> <contact>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<recipient>#{data[:recipient]}</recipient> <recipient>#{data[:recipient]}</recipient>
@ -11,7 +10,7 @@ module DiasporaFederation
<sharing>#{data[:sharing]}</sharing> <sharing>#{data[:sharing]}</sharing>
</contact> </contact>
XML XML
}
let(:string) { "Contact:#{data[:author]}:#{data[:recipient]}" } let(:string) { "Contact:#{data[:author]}:#{data[:recipient]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -19,8 +19,7 @@ module DiasporaFederation
) )
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<conversation> <conversation>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{parent.guid}</guid> <guid>#{parent.guid}</guid>
@ -30,7 +29,7 @@ module DiasporaFederation
#{data[:messages].map {|a| a.to_xml.to_s.indent(2) }.join("\n")} #{data[:messages].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
</conversation> </conversation>
XML XML
}
let(:string) { "Conversation:#{data[:guid]}" } let(:string) { "Conversation:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"
@ -38,8 +37,8 @@ XML
it_behaves_like "an XML Entity", %i(parent parent_guid) it_behaves_like "an XML Entity", %i(parent parent_guid)
context "default values" do context "default values" do
let(:minimal_xml) { it "allows no nested messages" do
<<-XML minimal_xml = <<-XML
<conversation> <conversation>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{parent.guid}</guid> <guid>#{parent.guid}</guid>
@ -47,10 +46,8 @@ XML
<created_at>#{data[:created_at]}</created_at> <created_at>#{data[:created_at]}</created_at>
<participant_handles>#{data[:participants]}</participant_handles> <participant_handles>#{data[:participants]}</participant_handles>
</conversation> </conversation>
XML XML
}
it "allows no nested messages" do
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root) parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
expect(parsed_instance.messages).to eq([]) expect(parsed_instance.messages).to eq([])
end end

View file

@ -12,8 +12,7 @@ module DiasporaFederation
).send(:xml_elements).merge(parent: parent_entity) ).send(:xml_elements).merge(parent: parent_entity)
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<like> <like>
<positive>#{data[:positive]}</positive> <positive>#{data[:positive]}</positive>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -24,7 +23,7 @@ module DiasporaFederation
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</like> </like>
XML XML
}
let(:string) { "Like:#{data[:guid]}:Post:#{parent.guid}" } let(:string) { "Like:#{data[:guid]}:Post:#{parent.guid}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"
@ -55,7 +54,7 @@ XML
<author_signature>#{data[:author_signature]}</author_signature> <author_signature>#{data[:author_signature]}</author_signature>
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</like> </like>
XML XML
expect { expect {
DiasporaFederation::Entities::Like.from_xml(Nokogiri::XML::Document.parse(broken_xml).root) DiasporaFederation::Entities::Like.from_xml(Nokogiri::XML::Document.parse(broken_xml).root)

View file

@ -2,15 +2,14 @@ module DiasporaFederation
describe Entities::Location do describe Entities::Location do
let(:data) { FactoryGirl.attributes_for(:location_entity) } let(:data) { FactoryGirl.attributes_for(:location_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<location> <location>
<address>#{data[:address]}</address> <address>#{data[:address]}</address>
<lat>#{data[:lat]}</lat> <lat>#{data[:lat]}</lat>
<lng>#{data[:lng]}</lng> <lng>#{data[:lng]}</lng>
</location> </location>
XML XML
}
let(:string) { "Location" } let(:string) { "Location" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -7,8 +7,7 @@ module DiasporaFederation
.send(:xml_elements).merge(parent: parent_entity) .send(:xml_elements).merge(parent: parent_entity)
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<message> <message>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid> <parent_guid>#{parent.guid}</parent_guid>
@ -20,7 +19,7 @@ module DiasporaFederation
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</message> </message>
XML XML
}
let(:string) { "Message:#{data[:guid]}:#{parent.guid}" } let(:string) { "Message:#{data[:guid]}:#{parent.guid}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -12,8 +12,7 @@ module DiasporaFederation
).send(:xml_elements).merge(parent: parent_entity) ).send(:xml_elements).merge(parent: parent_entity)
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<participation> <participation>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<target_type>#{parent.entity_type}</target_type> <target_type>#{parent.entity_type}</target_type>
@ -23,7 +22,7 @@ module DiasporaFederation
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</participation> </participation>
XML XML
}
let(:string) { "Participation:#{data[:guid]}:Post:#{parent.guid}" } let(:string) { "Participation:#{data[:guid]}:Post:#{parent.guid}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -2,8 +2,7 @@ module DiasporaFederation
describe Entities::Person do describe Entities::Person do
let(:data) { FactoryGirl.attributes_for(:person_entity) } let(:data) { FactoryGirl.attributes_for(:person_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<person> <person>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
@ -26,7 +25,7 @@ module DiasporaFederation
<exported_key>#{data[:exported_key]}</exported_key> <exported_key>#{data[:exported_key]}</exported_key>
</person> </person>
XML XML
}
let(:string) { "Person:#{data[:guid]}" } let(:string) { "Person:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -2,8 +2,7 @@ module DiasporaFederation
describe Entities::Photo do describe Entities::Photo do
let(:data) { FactoryGirl.attributes_for(:photo_entity) } let(:data) { FactoryGirl.attributes_for(:photo_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<photo> <photo>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
@ -17,7 +16,7 @@ module DiasporaFederation
<width>#{data[:width]}</width> <width>#{data[:width]}</width>
</photo> </photo>
XML XML
}
let(:string) { "Photo:#{data[:guid]}" } let(:string) { "Photo:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"
@ -25,8 +24,8 @@ XML
it_behaves_like "an XML Entity" it_behaves_like "an XML Entity"
context "default values" do context "default values" do
let(:minimal_xml) { it "uses default values" do
<<-XML minimal_xml = <<-XML
<photo> <photo>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
@ -37,10 +36,8 @@ XML
<height>#{data[:height]}</height> <height>#{data[:height]}</height>
<width>#{data[:width]}</width> <width>#{data[:width]}</width>
</photo> </photo>
XML XML
}
it "uses default values" do
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root) parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
expect(parsed_instance.public).to be_falsey expect(parsed_instance.public).to be_falsey
expect(parsed_instance.text).to be_nil expect(parsed_instance.text).to be_nil

View file

@ -2,14 +2,13 @@ module DiasporaFederation
describe Entities::PollAnswer do describe Entities::PollAnswer do
let(:data) { FactoryGirl.attributes_for(:poll_answer_entity) } let(:data) { FactoryGirl.attributes_for(:poll_answer_entity) }
let(:xml) { let(:xml) { <<-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(:string) { "PollAnswer:#{data[:guid]}" } let(:string) { "PollAnswer:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -11,8 +11,7 @@ module DiasporaFederation
).send(:xml_elements).merge(parent: parent_entity) ).send(:xml_elements).merge(parent: parent_entity)
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<poll_participation> <poll_participation>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid> <parent_guid>#{parent.guid}</parent_guid>
@ -22,7 +21,7 @@ module DiasporaFederation
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
</poll_participation> </poll_participation>
XML XML
}
let(:string) { "PollParticipation:#{data[:guid]}:#{parent.guid}" } let(:string) { "PollParticipation:#{data[:guid]}:#{parent.guid}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -2,15 +2,14 @@ module DiasporaFederation
describe Entities::Poll do describe Entities::Poll do
let(:data) { FactoryGirl.attributes_for(:poll_entity) } let(:data) { FactoryGirl.attributes_for(:poll_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<poll> <poll>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<question>#{data[:question]}</question> <question>#{data[:question]}</question>
#{data[:poll_answers].map {|a| a.to_xml.to_s.indent(2) }.join("\n")} #{data[:poll_answers].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
</poll> </poll>
XML XML
}
let(:string) { "Poll:#{data[:guid]}" } let(:string) { "Poll:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -2,8 +2,7 @@ module DiasporaFederation
describe Entities::Profile do describe Entities::Profile do
let(:data) { FactoryGirl.attributes_for(:profile_entity) } let(:data) { FactoryGirl.attributes_for(:profile_entity) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<profile> <profile>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
<first_name>#{data[:first_name]}</first_name> <first_name>#{data[:first_name]}</first_name>
@ -20,7 +19,7 @@ module DiasporaFederation
<tag_string>#{data[:tag_string]}</tag_string> <tag_string>#{data[:tag_string]}</tag_string>
</profile> </profile>
XML XML
}
let(:string) { "Profile:#{data[:author]}" } let(:string) { "Profile:#{data[:author]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"
@ -28,15 +27,13 @@ XML
it_behaves_like "an XML Entity" it_behaves_like "an XML Entity"
context "default values" do context "default values" do
let(:minimal_xml) { it "uses default values" do
<<-XML minimal_xml = <<-XML
<profile> <profile>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
</profile> </profile>
XML XML
}
it "uses default values" do
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root) parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
expect(parsed_instance.first_name).to be_nil expect(parsed_instance.first_name).to be_nil
expect(parsed_instance.last_name).to be_nil expect(parsed_instance.last_name).to be_nil

View file

@ -21,8 +21,7 @@ module DiasporaFederation
end end
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<relayable_retraction> <relayable_retraction>
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature> <parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
<target_guid>#{data[:target_guid]}</target_guid> <target_guid>#{data[:target_guid]}</target_guid>
@ -31,7 +30,7 @@ module DiasporaFederation
<target_author_signature/> <target_author_signature/>
</relayable_retraction> </relayable_retraction>
XML XML
}
let(:string) { "RelayableRetraction:#{data[:target_type]}:#{data[:target_guid]}" } let(:string) { "RelayableRetraction:#{data[:target_type]}:#{data[:target_guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -234,8 +234,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) { let(:new_xml) { <<-XML }
<<-XML
<some_relayable> <some_relayable>
<diaspora_handle>#{author}</diaspora_handle> <diaspora_handle>#{author}</diaspora_handle>
<guid>#{guid}</guid> <guid>#{guid}</guid>
@ -246,7 +245,6 @@ XML
<parent_author_signature>#{sign_with_key(parent_pkey, new_signature_data)}</parent_author_signature> <parent_author_signature>#{sign_with_key(parent_pkey, new_signature_data)}</parent_author_signature>
</some_relayable> </some_relayable>
XML XML
}
it "doesn't drop unknown properties" do it "doesn't drop unknown properties" do
entity = SomeRelayable.from_xml(Nokogiri::XML::Document.parse(new_xml).root) entity = SomeRelayable.from_xml(Nokogiri::XML::Document.parse(new_xml).root)
@ -302,7 +300,7 @@ XML
<author_signature/> <author_signature/>
<parent_author_signature/> <parent_author_signature/>
</some_relayable> </some_relayable>
XML XML
expect { expect {
SomeRelayable.from_xml(Nokogiri::XML::Document.parse(broken_xml).root) SomeRelayable.from_xml(Nokogiri::XML::Document.parse(broken_xml).root)

View file

@ -2,14 +2,13 @@ module DiasporaFederation
describe Entities::Request do describe Entities::Request do
let(:data) { FactoryGirl.attributes_for(:request_entity) } let(:data) { FactoryGirl.attributes_for(:request_entity) }
let(:xml) { let(:xml) { <<-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>
</request> </request>
XML XML
}
let(:string) { "Request:#{data[:author]}:#{data[:recipient]}" } let(:string) { "Request:#{data[:author]}:#{data[:recipient]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -3,8 +3,7 @@ module DiasporaFederation
let(:root) { FactoryGirl.create(:post, author: bob) } let(:root) { FactoryGirl.create(:post, author: bob) }
let(:data) { FactoryGirl.attributes_for(:reshare_entity, root_guid: root.guid, root_author: bob.diaspora_id) } let(:data) { FactoryGirl.attributes_for(:reshare_entity, root_guid: root.guid, root_author: bob.diaspora_id) }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<reshare> <reshare>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -15,7 +14,7 @@ module DiasporaFederation
<public>#{data[:public]}</public> <public>#{data[:public]}</public>
</reshare> </reshare>
XML XML
}
let(:string) { "Reshare:#{data[:guid]}:#{data[:root_guid]}" } let(:string) { "Reshare:#{data[:guid]}:#{data[:root_guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"
@ -23,8 +22,8 @@ XML
it_behaves_like "an XML Entity" it_behaves_like "an XML Entity"
context "default values" do context "default values" do
let(:minimal_xml) { it "uses default values" do
<<-XML minimal_xml = <<-XML
<reshare> <reshare>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -32,10 +31,8 @@ XML
<root_diaspora_id>#{data[:root_author]}</root_diaspora_id> <root_diaspora_id>#{data[:root_author]}</root_diaspora_id>
<root_guid>#{data[:root_guid]}</root_guid> <root_guid>#{data[:root_guid]}</root_guid>
</reshare> </reshare>
XML XML
}
it "uses default values" do
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root) parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
expect(parsed_instance.public).to be_truthy expect(parsed_instance.public).to be_truthy
expect(parsed_instance.provider_display_name).to be_nil expect(parsed_instance.provider_display_name).to be_nil

View file

@ -11,15 +11,14 @@ module DiasporaFederation
) )
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<retraction> <retraction>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
<post_guid>#{data[:target_guid]}</post_guid> <post_guid>#{data[:target_guid]}</post_guid>
<type>#{data[:target_type]}</type> <type>#{data[:target_type]}</type>
</retraction> </retraction>
XML XML
}
let(:string) { "Retraction:#{data[:target_type]}:#{data[:target_guid]}" } let(:string) { "Retraction:#{data[:target_type]}:#{data[:target_guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -12,8 +12,7 @@ module DiasporaFederation
).send(:xml_elements).merge(target: target_entity) ).send(:xml_elements).merge(target: target_entity)
} }
let(:xml) { let(:xml) { <<-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>
@ -21,7 +20,7 @@ module DiasporaFederation
<target_author_signature>#{data[:target_author_signature]}</target_author_signature> <target_author_signature>#{data[:target_author_signature]}</target_author_signature>
</signed_retraction> </signed_retraction>
XML XML
}
let(:string) { "SignedRetraction:#{data[:target_type]}:#{data[:target_guid]}" } let(:string) { "SignedRetraction:#{data[:target_type]}:#{data[:target_guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"

View file

@ -13,8 +13,7 @@ module DiasporaFederation
) )
} }
let(:xml) { let(:xml) { <<-XML }
<<-XML
<status_message> <status_message>
<diaspora_handle>#{data[:author]}</diaspora_handle> <diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
@ -52,8 +51,8 @@ module DiasporaFederation
</location> </location>
<public>#{data[:public]}</public> <public>#{data[:public]}</public>
</status_message> </status_message>
XML XML
}
let(:string) { "StatusMessage:#{data[:guid]}" } let(:string) { "StatusMessage:#{data[:guid]}" }
it_behaves_like "an Entity subclass" it_behaves_like "an Entity subclass"
@ -61,18 +60,16 @@ module DiasporaFederation
it_behaves_like "an XML Entity" it_behaves_like "an XML Entity"
context "default values" do context "default values" do
let(:minimal_xml) { it "uses default values" do
<<-XML minimal_xml = <<-XML
<status_message> <status_message>
<author>#{data[:author]}</author> <author>#{data[:author]}</author>
<guid>#{data[:guid]}</guid> <guid>#{data[:guid]}</guid>
<created_at>#{data[:created_at]}</created_at> <created_at>#{data[:created_at]}</created_at>
<text>#{data[:text]}</text> <text>#{data[:text]}</text>
</status_message> </status_message>
XML XML
}
it "uses default values" do
parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root) parsed_instance = DiasporaFederation::Salmon::XmlPayload.unpack(Nokogiri::XML::Document.parse(minimal_xml).root)
expect(parsed_instance.photos).to eq([]) expect(parsed_instance.photos).to eq([])
expect(parsed_instance.location).to be_nil expect(parsed_instance.location).to be_nil

View file

@ -2,8 +2,7 @@ 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(:payload) { Salmon::XmlPayload.pack(entity) } let(:payload) { Salmon::XmlPayload.pack(entity) }
let(:entity_xml) { let(:entity_xml) { <<-XML.strip }
<<-XML.strip
<XML> <XML>
<post> <post>
<test_entity> <test_entity>
@ -12,7 +11,6 @@ module DiasporaFederation
</post> </post>
</XML> </XML>
XML XML
}
describe ".pack" do describe ".pack" do
it "expects an Entity as param" do it "expects an Entity as param" do