all non-cucumber tests are passing

This commit is contained in:
Reinier Balt 2012-04-27 14:22:16 +02:00
parent 13b58f3a10
commit 63175c115b
46 changed files with 248 additions and 505 deletions

View file

@ -0,0 +1,29 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe MessageGateway do
before :each do
todo = mock_model(Todo, :description= => nil, :raw_notes= => nil, :context_id= => nil, :save! => nil)
@user = mock_model(User,
:prefs => mock_model(Preference, :sms_context => mock_model(Context)),
:todos => mock('Todo collection', :find => nil, :build => todo),
:contexts => mock('Context collection', :exists? => true, :find => nil))
User.stub!(:find).and_return(@user)
end
def load_message(filename)
MessageGateway.receive(File.read(File.join(RAILS_ROOT, 'test', 'fixtures', filename)))
end
it "should dispatch on From: or To: according to site.yml" do
SITE_CONFIG['email_dispatch'] = 'from'
User.should_receive(:find).with(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", '5555555555@tmomail.net'])
load_message('sample_email.txt')
SITE_CONFIG['email_dispatch'] = 'to'
User.should_receive(:find).with(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", 'gtd@tracks.com'])
load_message('sample_email.txt')
end
end