Sha256: 5a0675f6f3cf3bc91f84faf1d1ab455aeab7578a8d449b046e69d02d88abf805

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ActsAsIcontact::Contact do
  
  it "defaults to searching on all contacts regardless of list status" do
    ActsAsIcontact::Contact.base.expects(:[]).with(regexp_matches(/status=total/)).returns(stub(:get => '{"contacts":[]}'))
    r = ActsAsIcontact::Contact.find(:all)
  end
  
  it "requires email address" do
    c = ActsAsIcontact::Contact.new
    lambda{c.save}.should raise_error(ActsAsIcontact::ValidationError, "Missing required fields: email")
  end
  
  context "associations" do
    # We have _one_ really good contact set up here
    before(:each) do
      @john = ActsAsIcontact::Contact.first(:firstName => "John", :lastName => "Test")
    end
  
    it "knows which lists it's subscribed to" do
      @john.lists.first.should == ActsAsIcontact::List.find(444444)
    end
    
    it "can subscribe oneself to a list" do
      conn = mock('Class Connection')
      conn.expects(:post).with(regexp_matches(/444444/) && regexp_matches(/333333/)).returns('{"subscriptions":{}}')
      ActsAsIcontact::Subscription.expects(:connection).returns(conn)
      @john.subscribe(444444)
    end
    
    it "knows its history" do
      @john.history.count.should == 4
    end
  end
    
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.4.0 spec/resources/contact_spec.rb
SFEley-acts_as_icontact-0.4.2 spec/resources/contact_spec.rb
SFEley-acts_as_icontact-0.4.3 spec/resources/contact_spec.rb
acts_as_icontact-0.4.3 spec/resources/contact_spec.rb
acts_as_icontact-0.4.2 spec/resources/contact_spec.rb
acts_as_icontact-0.4.0 spec/resources/contact_spec.rb