IZ Made the specs pass, time to clean

This commit is contained in:
Raphael Sofaer 2010-06-15 20:38:14 -07:00
parent c4b931c309
commit 34127b070a
2 changed files with 35 additions and 6 deletions

View file

@ -26,6 +26,11 @@ class StatusMessage
def self.retrieve_from_friend(friend)
StatusMessages.from_xml `curl #{friend.url}status_messages.xml --user a@a.com:aaaaaa`
end
def ==(other)
(self.message == other.message) && (self.owner == other.owner)
end
protected
def set_default_owner

View file

@ -53,20 +53,44 @@ describe StatusMessage do
describe "retrieving" do
before do
@remote = Factory.create(:friend, :url => "http://localhost:1254/")
@remote_xml = (0..5).collect{Factory.create(:status_message).to_xml}
StatusMessages = StatusMessagesHelper::StatusMessages
#@remote_messages = (0..5).collect {|a| Factory.build(:status_message)}
#stub with response of @remote_msg.xml
end
it "should marshal xml and serialize it" do
messages = StatusMessages.new(@remote_xml)
unreadable_xml = messages.to_xml.to_s.sub("\t\t","\t")
unreadable_xml.include?(remote_xml.first.to_s).should be true
it "should marshal xml and serialize it without error" do
StatusMessages.from_xml(@@remote_xml).to_xml.to_s.sub("/t<","<").should == @@remote_xml
end
it "marshal retrieved xml" do
StatusMessage.retrieve_from_friend(@remote).to_xml.should == StatusMessages.from_xml(@remote_xml).to_xml
remote_msgs = StatusMessage.retrieve_from_friend(@remote)
local_msgs = StatusMessages.from_xml(@@remote_xml)
remote_msgs.statusmessages.each{ |m| local_msgs.statusmessages.include?(m).should be_true}
local_msgs.statusmessages.each{ |m| remote_msgs.statusmessages.include?(m).should be_true}
# .from_xml == @remote_messages
end
end
end
@@remote_xml =
"<statusmessages>
<statusmessage>
<message>jimmy's 22 whales</message>
<owner>tester@yahoo.com</owner>
</statusmessage>
<statusmessage>
<message>jimmy's 23 whales</message>
<owner>tester@yahoo.com</owner>
</statusmessage>
<statusmessage>
<message>jimmy's 24 whales</message>
<owner>tester@yahoo.com</owner>
</statusmessage>
<statusmessage>
<message>jimmy's 25 whales</message>
<owner>tester@yahoo.com</owner>
</statusmessage>
<statusmessage>
<message>jimmy's 26 whales</message>
<owner>tester@yahoo.com</owner>
</statusmessage>
</statusmessages>"