RS, IZ; stubbed out and wrapped curl backtick
This commit is contained in:
parent
34127b070a
commit
8213443afd
3 changed files with 12 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ class StatusMessage
|
|||
include Mongoid::Timestamps
|
||||
include ROXML
|
||||
include StatusMessagesHelper
|
||||
require 'lib/net/curl'
|
||||
|
||||
xml_accessor :message
|
||||
xml_accessor :owner
|
||||
|
|
@ -24,7 +25,7 @@ class StatusMessage
|
|||
end
|
||||
|
||||
def self.retrieve_from_friend(friend)
|
||||
StatusMessages.from_xml `curl #{friend.url}status_messages.xml --user a@a.com:aaaaaa`
|
||||
StatusMessages.from_xml Curl.curl(friend.url+"status_messages.xml")
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
|
|
|
|||
6
lib/net/curl.rb
Normal file
6
lib/net/curl.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class Curl
|
||||
def self.curl(s)
|
||||
`curl #{s}`
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
include StatusMessagesHelper
|
||||
|
||||
describe StatusMessage do
|
||||
before do
|
||||
|
|
@ -52,21 +53,17 @@ describe StatusMessage do
|
|||
|
||||
describe "retrieving" do
|
||||
before do
|
||||
@remote = Factory.create(:friend, :url => "http://localhost:1254/")
|
||||
StatusMessages = StatusMessagesHelper::StatusMessages
|
||||
#@remote_messages = (0..5).collect {|a| Factory.build(:status_message)}
|
||||
#stub with response of @remote_msg.xml
|
||||
@remote = Factory.create(:friend, :url => "fakeurl")#http://localhost:1254/")
|
||||
Curl.stub!(:curl).and_return(@@remote_xml)
|
||||
end
|
||||
it "should marshal xml and serialize it without error" do
|
||||
StatusMessages.from_xml(@@remote_xml).to_xml.to_s.sub("/t<","<").should == @@remote_xml
|
||||
StatusMessages.from_xml(@@remote_xml).to_xml.to_s.should == @@remote_xml
|
||||
end
|
||||
it "marshal retrieved xml" do
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue