Sha256: 82f6a845b70fa18efa2cffe9b14449309b82bb382af7d31af8cabf16102f5a65

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

share_as :Callbacks do
  context "callbacks" do
    before(:each) do
      @class.acts_as_icontact :list => "First Test", :surname => :lastName
      @person = @class.new(:firstName => "John", :surname => "Smith", :email => "john@example.org")
    end
    
    context "for creation" do
      it "creates a new contact" do
        conn = mock('Class Connection')
        conn.expects(:post).with(regexp_matches(/Smith/)).returns('{"contacts":{}}')
        ActsAsIcontact::Contact.expects(:connection).returns(conn)
        @person.save
      end
      
      it "updates the Person with the results of the contact creation" do
        @person.save
        @person.icontact_id.should == 333444
      end
      
      it "subscribes the Person to any lists" do
        ActsAsIcontact::Contact.any_instance.expects(:subscribe).with("First Test").returns(true)
        @person.save
      end
    end
    
    context "for update" do
      before(:each) do
        @person.save
        @person.surname = "Nielsen Hayden"
      end
      
      it "updates the contact with the new fields" do
        conn = mock('Instance Connection')
        conn.expects(:post).with(regexp_matches(/Nielsen Hayden/)).returns('{"contact":{}}')
        ActsAsIcontact::Contact.any_instance.expects(:connection).returns(conn)
        @person.save
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.3.0 spec/rails_spec/callbacks_spec.rb
SFEley-acts_as_icontact-0.3.2 spec/rails_spec/callbacks_spec.rb
SFEley-acts_as_icontact-0.4.0 spec/rails_spec/callbacks_spec.rb
SFEley-acts_as_icontact-0.4.2 spec/rails_spec/callbacks_spec.rb
SFEley-acts_as_icontact-0.4.3 spec/rails_spec/callbacks_spec.rb
acts_as_icontact-0.4.3 spec/rails_spec/callbacks_spec.rb
acts_as_icontact-0.4.2 spec/rails_spec/callbacks_spec.rb
acts_as_icontact-0.4.0 spec/rails_spec/callbacks_spec.rb
acts_as_icontact-0.3.2 spec/rails_spec/callbacks_spec.rb
acts_as_icontact-0.3.0 spec/rails_spec/callbacks_spec.rb