- New and older specs adjustments;
- Move the specs to use FactoryGirl; - Replace use of "context" in specs with "describe".
This commit is contained in:
parent
f12a4c21db
commit
b8b52fc60d
24 changed files with 80 additions and 135 deletions
|
|
@ -173,6 +173,7 @@ FactoryGirl.define do
|
|||
diaspora_id
|
||||
public(true)
|
||||
created_at { DateTime.now.utc }
|
||||
provider_display_name { "the testsuite" }
|
||||
end
|
||||
|
||||
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::AccountDeletion do
|
||||
let(:data) { {diaspora_id: "me@goes.byebye.tld"} }
|
||||
let(:data) { FactoryGirl.attributes_for(:account_deletion_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<account_deletion>
|
||||
<diaspora_handle>me@goes.byebye.tld</diaspora_handle>
|
||||
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
||||
</account_deletion>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,16 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Comment do
|
||||
let(:data) {
|
||||
{guid: "0123456789abcdef",
|
||||
parent_guid: "fedcba9876543210",
|
||||
parent_author_signature: "BBBBBB==",
|
||||
author_signature: "AAAAAA==",
|
||||
text: "my comment text",
|
||||
diaspora_id: "bob@pod.somedomain.tld"}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:comment_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<comment>
|
||||
<guid>0123456789abcdef</guid>
|
||||
<parent_guid>fedcba9876543210</parent_guid>
|
||||
<parent_author_signature>BBBBBB==</parent_author_signature>
|
||||
<author_signature>AAAAAA==</author_signature>
|
||||
<text>my comment text</text>
|
||||
<diaspora_handle>bob@pod.somedomain.tld</diaspora_handle>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<parent_guid>#{data[:parent_guid]}</parent_guid>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<text>#{data[:text]}</text>
|
||||
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
||||
</comment>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,17 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Like do
|
||||
let(:data) {
|
||||
{positive: true,
|
||||
guid: "0123456789abcdef",
|
||||
target_type: "Post",
|
||||
parent_guid: "fedcba9876543210",
|
||||
parent_author_signature: "BBBBBB==",
|
||||
author_signature: "AAAAAA==",
|
||||
diaspora_id: "luke@diaspora.example.tld"}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:like_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<like>
|
||||
<positive>true</positive>
|
||||
<guid>0123456789abcdef</guid>
|
||||
<target_type>Post</target_type>
|
||||
<parent_guid>fedcba9876543210</parent_guid>
|
||||
<parent_author_signature>BBBBBB==</parent_author_signature>
|
||||
<author_signature>AAAAAA==</author_signature>
|
||||
<diaspora_handle>luke@diaspora.example.tld</diaspora_handle>
|
||||
<positive>#{data[:positive]}</positive>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<parent_guid>#{data[:parent_guid]}</parent_guid>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
<author_signature>#{data[:author_signature]}</author_signature>
|
||||
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
||||
</like>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Participation do
|
||||
let(:data) {
|
||||
{guid: "0123456789abcdef",
|
||||
target_type: "Post",
|
||||
parent_guid: "fedcba9876543210",
|
||||
parent_author_signature: "BBBBBB==",
|
||||
author_signature: "AAAAAA==",
|
||||
diaspora_id: "luke@diaspora.example.tld"}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:participation_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
|
|
|
|||
|
|
@ -1,21 +1,15 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::RelayableRetraction do
|
||||
let(:data) {
|
||||
{parent_author_signature: "AAAAAA=",
|
||||
target_guid: "0123456789abcdef",
|
||||
target_type: "Comment",
|
||||
sender_id: "luke@diaspora.example.tld",
|
||||
target_author_signature: "BBBBBB="}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:relayable_retraction_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<relayable_retraction>
|
||||
<parent_author_signature>AAAAAA=</parent_author_signature>
|
||||
<target_guid>0123456789abcdef</target_guid>
|
||||
<target_type>Comment</target_type>
|
||||
<sender_handle>luke@diaspora.example.tld</sender_handle>
|
||||
<target_author_signature>BBBBBB=</target_author_signature>
|
||||
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:sender_id]}</sender_handle>
|
||||
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
||||
</relayable_retraction>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Request do
|
||||
let(:data) {
|
||||
{sender_id: "alice@somepod.org",
|
||||
recipient_id: "bob@otherpod.net"}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:request_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<request>
|
||||
<sender_handle>alice@somepod.org</sender_handle>
|
||||
<recipient_handle>bob@otherpod.net</recipient_handle>
|
||||
<sender_handle>#{data[:sender_id]}</sender_handle>
|
||||
<recipient_handle>#{data[:recipient_id]}</recipient_handle>
|
||||
</request>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,17 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Reshare do
|
||||
before do
|
||||
@datetime = DateTime.now.utc
|
||||
end
|
||||
|
||||
let(:data) {
|
||||
{root_diaspora_id: "robert_root@pod.example.tld",
|
||||
root_guid: "fedcba9876543210",
|
||||
guid: "0123456789abcdef",
|
||||
diaspora_id: "alice@diaspora.domain.tld",
|
||||
public: true,
|
||||
created_at: @datetime,
|
||||
provider_display_name: "mobile"}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:reshare_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<reshare>
|
||||
<root_diaspora_id>robert_root@pod.example.tld</root_diaspora_id>
|
||||
<root_guid>fedcba9876543210</root_guid>
|
||||
<guid>0123456789abcdef</guid>
|
||||
<diaspora_handle>alice@diaspora.domain.tld</diaspora_handle>
|
||||
<public>true</public>
|
||||
<created_at>#{@datetime}</created_at>
|
||||
<provider_display_name>mobile</provider_display_name>
|
||||
<root_diaspora_id>#{data[:root_diaspora_id]}</root_diaspora_id>
|
||||
<root_guid>#{data[:root_guid]}</root_guid>
|
||||
<guid>#{data[:guid]}</guid>
|
||||
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
||||
<public>#{data[:public]}</public>
|
||||
<created_at>#{data[:created_at]}</created_at>
|
||||
<provider_display_name>#{data[:provider_display_name]}</provider_display_name>
|
||||
</reshare>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::Retraction do
|
||||
let(:data) {
|
||||
{post_guid: "0123456789abcdef",
|
||||
diaspora_id: "luke@diaspora.example.tld",
|
||||
type: "StatusMessage"}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:retraction_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<retraction>
|
||||
<post_guid>0123456789abcdef</post_guid>
|
||||
<diaspora_handle>luke@diaspora.example.tld</diaspora_handle>
|
||||
<type>StatusMessage</type>
|
||||
<post_guid>#{data[:post_guid]}</post_guid>
|
||||
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
|
||||
<type>#{data[:type]}</type>
|
||||
</retraction>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,14 @@
|
|||
module DiasporaFederation
|
||||
describe Entities::SignedRetraction do
|
||||
let(:data) {
|
||||
{target_guid: "0123456789abcdef",
|
||||
target_type: "StatusMessage",
|
||||
sender_id: "luke@diaspora.example.tld",
|
||||
target_author_signature: "AAAAAA=="}
|
||||
}
|
||||
let(:data) { FactoryGirl.attributes_for(:signed_retraction_entity) }
|
||||
|
||||
let(:xml) {
|
||||
<<-XML
|
||||
<signed_retraction>
|
||||
<target_guid>0123456789abcdef</target_guid>
|
||||
<target_type>StatusMessage</target_type>
|
||||
<sender_handle>luke@diaspora.example.tld</sender_handle>
|
||||
<target_author_signature>AAAAAA==</target_author_signature>
|
||||
<target_guid>#{data[:target_guid]}</target_guid>
|
||||
<target_type>#{data[:target_type]}</target_type>
|
||||
<sender_handle>#{data[:sender_id]}</sender_handle>
|
||||
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
|
||||
</signed_retraction>
|
||||
XML
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,15 +15,15 @@ module DiasporaFederation
|
|||
end
|
||||
end
|
||||
|
||||
context "#author_signature and #parent_author_signature" do
|
||||
%i(author_signature parent_author_signature).each do |prop|
|
||||
%i(author_signature parent_author_signature).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#text" do
|
||||
describe "#text" do
|
||||
it_behaves_like "a property with a value validation/restriction" do
|
||||
let(:property) { :text }
|
||||
let(:wrong_values) { ["", "a" * 65_536] }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module DiasporaFederation
|
|||
let(:property) { :guid }
|
||||
end
|
||||
|
||||
context "participant_ids" do
|
||||
describe "participant_ids" do
|
||||
# must not contain more than 20 participant handles
|
||||
it_behaves_like "a property with a value validation/restriction" do
|
||||
let(:property) { :participant_ids }
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ module DiasporaFederation
|
|||
|
||||
%i(photo_large_url photo_medium_url photo_small_url).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property with data-types restriction" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
let(:wrong_values) { [nil, ""] }
|
||||
let(:correct_values) { [] }
|
||||
end
|
||||
|
||||
it_behaves_like "a url path validator" do
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ module DiasporaFederation
|
|||
end
|
||||
end
|
||||
|
||||
context "#author_signature and #parent_author_signature" do
|
||||
%i(author_signature parent_author_signature).each do |prop|
|
||||
%i(author_signature parent_author_signature).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ module DiasporaFederation
|
|||
let(:entity) { :location_entity }
|
||||
it_behaves_like "a common validator"
|
||||
|
||||
context "#lat and #lng" do
|
||||
%i(lat lng).each do |prop|
|
||||
%i(lat lng).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ module DiasporaFederation
|
|||
let(:mandatory) { true }
|
||||
end
|
||||
|
||||
context "#guid, #parent_guid, #conversation_guid" do
|
||||
%i(guid parent_guid conversation_guid).each do |prop|
|
||||
%i(guid parent_guid conversation_guid).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a guid validator" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#author_signature and #parent_author_signature" do
|
||||
%i(author_signature parent_author_signature).each do |prop|
|
||||
%i(author_signature parent_author_signature).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ module DiasporaFederation
|
|||
let(:mandatory) { true }
|
||||
end
|
||||
|
||||
context "#guid, #parent_guid" do
|
||||
%i(guid parent_guid).each do |prop|
|
||||
%i(guid parent_guid).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a guid validator" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#target_type and #author_signature and #parent_author_signature" do
|
||||
%i(target_type author_signature parent_author_signature).each do |prop|
|
||||
%i(target_type author_signature parent_author_signature).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ module DiasporaFederation
|
|||
let(:mandatory) { true }
|
||||
end
|
||||
|
||||
context "#guid, #status_message_guid" do
|
||||
%i(guid status_message_guid).each do |prop|
|
||||
%i(guid status_message_guid).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a guid validator" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
@ -21,16 +21,16 @@ module DiasporaFederation
|
|||
let(:property) { :public }
|
||||
end
|
||||
|
||||
context "#remote_photo_path, #remote_photo_name" do
|
||||
%i(remote_photo_name remote_photo_path).each do |prop|
|
||||
%i(remote_photo_name remote_photo_path).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#height, #width" do
|
||||
%i(height width).each do |prop|
|
||||
%i(height width).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property with a value validation/restriction" do
|
||||
let(:property) { prop }
|
||||
let(:wrong_values) { [true, :num, "asdf"] }
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ module DiasporaFederation
|
|||
let(:property) { :target_guid }
|
||||
end
|
||||
|
||||
context "#parent_author_signature, #target_author_signature" do
|
||||
%i(parent_author_signature target_author_signature).each do |prop|
|
||||
%i(parent_author_signature target_author_signature).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ module DiasporaFederation
|
|||
|
||||
it_behaves_like "a common validator"
|
||||
|
||||
context "#sender_id, #recipient_id" do
|
||||
%i(sender_id recipient_id).each do |prop|
|
||||
%i(sender_id recipient_id).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a diaspora id validator" do
|
||||
let(:property) { prop }
|
||||
let(:mandatory) { true }
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ module DiasporaFederation
|
|||
let(:entity) { :reshare_entity }
|
||||
it_behaves_like "a common validator"
|
||||
|
||||
context "#root_diaspora_id, #diaspora_id" do
|
||||
%i(root_diaspora_id diaspora_id).each do |prop|
|
||||
%i(root_diaspora_id diaspora_id).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a diaspora id validator" do
|
||||
let(:property) { prop }
|
||||
let(:mandatory) { true }
|
||||
|
|
@ -12,8 +12,8 @@ module DiasporaFederation
|
|||
end
|
||||
end
|
||||
|
||||
context "#root_guid, #guid" do
|
||||
%i(root_guid guid).each do |prop|
|
||||
%i(root_guid guid).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a guid validator" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module DiasporaFederation
|
|||
let(:mandatory) { true }
|
||||
end
|
||||
|
||||
context "#type" do
|
||||
describe "#type" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { :type }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ module DiasporaFederation
|
|||
let(:property) { :target_guid }
|
||||
end
|
||||
|
||||
context "#target_type, #target_author_signature" do
|
||||
%i(target_type target_author_signature).each do |prop|
|
||||
%i(target_type target_author_signature).each do |prop|
|
||||
describe "##{prop}" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { prop }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,10 +5,8 @@ module DiasporaFederation
|
|||
it_behaves_like "a common validator"
|
||||
|
||||
describe "#acct_uri" do
|
||||
it_behaves_like "a property with data-types restriction" do
|
||||
it_behaves_like "a property that mustn't be empty" do
|
||||
let(:property) { :acct_uri }
|
||||
let(:wrong_values) { [nil, ""] }
|
||||
let(:correct_values) { [] }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue