spec/lib/flapjack/data/message_spec.rb in flapjack-0.7.6 vs spec/lib/flapjack/data/message_spec.rb in flapjack-0.7.7

- old
+ new

@@ -1,12 +1,36 @@ require 'spec_helper' require 'flapjack/data/message' describe Flapjack::Data::Message do - it "is generated for a contact" + let(:contact) { mock(Flapjack::Data::Contact) } - it "assigns itself an ID" + it "assigns itself an ID" do + message = Flapjack::Data::Message.for_contact(:contact => contact) + mid = message.id + mid.should_not be_nil + mid.should be_a(String) + end - it "returns its contained data" + it "returns its contained data" do + notification = mock(Flapjack::Data::Notification) + notification.should_receive(:contents).and_return('notification' => 'contents') + + message = Flapjack::Data::Message.for_contact(:contact => contact) + message.notification = notification + message.medium = 'email' + message.address = 'jja@example.com' + + contact.should_receive(:id).and_return('23') + contact.should_receive(:first_name).and_return('James') + contact.should_receive(:last_name).and_return('Jameson') + + message.contents.should include('notification' => 'contents', + 'contact_id' => '23', + 'contact_first_name' => 'James', + 'contact_last_name' => 'Jameson', + 'media' => 'email', + 'address' => 'jja@example.com') + end end \ No newline at end of file