Sha256: 1f796fd552d77e472969bcc8886b50cbbcce60ffa3a600f341f145e472bd60c8

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 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
    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

2 entries across 2 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.2.4 spec/rails_spec/callbacks_spec.rb
acts_as_icontact-0.2.4 spec/rails_spec/callbacks_spec.rb