require 'spec_helper' describe "ExternalMessage", "converting to xml" do before do @external_message_a = Caren::ExternalMessage.new( :person_name => "Andre Foeken", :external_person_id => 1, :body => "Test message", :external_id => 1, :in_reply_to_id => nil ) @external_message_b = Caren::ExternalMessage.new( :person_name => "Ria Foeken", :external_person_id => 2, :body => "Test message reply", :external_id => 2, :in_reply_to_id => 99 ) end it "should be able to convert a link to valid xml" do @external_message_a.should convert_to_valid_caren_xml end it "should be able to convert an array of links to valid xml" do [@external_message_a,@external_message_b].should convert_to_valid_caren_array_xml end end describe "ExternalMessage", "REST methods" do before do FakeWeb.register_uri(:post, Caren::ExternalMessage.resource_url(1), :status => 201, :signature => Caren::Api.sign ) FakeWeb.register_uri(:delete, Caren::ExternalMessage.resource_url(1,1), :signature => Caren::Api.sign ) end it "should be able to create an external message" do lambda{ Caren::ExternalMessage.new( :person_name => "Andre Foeken", :external_person_id => 1, :body => "Test message", :external_id => 1, :subject_id => 1 ).create }.should_not raise_error end it "should be able to delete an external message" do lambda{ Caren::ExternalMessage.new( :subject_id => 1, :id => 1 ).delete }.should_not raise_error end end