Sha256: 12a39e7b4f41e71dbbd9ede50e8d762146e7caa42365a790a151b62314fb0471

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

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

describe Pardot::Objects::Prospects do
  
  before do
    @client = create_client
  end
  
  describe "query" do
    
    def sample_results
      %(<?xml version="1.0" encoding="UTF-8"?>
      <rsp stat="ok" version="1.0">
        <result>
          <total_results>2</total_results>
          <prospect>
            <first_name>Jim</first_name>
            <last_name>Smith</last_name>
          </prospect>
          <prospect>
            <first_name>Sue</first_name>
            <last_name>Green</last_name>
          </prospect>
        </result>
      </rsp>)
    end
    
    it "should take in some arguments" do
      fake_get "/api/prospect/version/3/do/query?assigned=true&format=simple", sample_results
      
      @client.prospects.query(:assigned => true).should == {"total_results" => 2, 
        "prospect"=>[
          {"last_name"=>"Smith", "first_name"=>"Jim"}, 
          {"last_name"=>"Green", "first_name"=>"Sue"}
        ]}
      assert_authorization_header
    end
    
  end
  
  describe "create" do
    
    def sample_results
      %(<?xml version="1.0" encoding="UTF-8"?>
      <rsp stat="ok" version="1.0">
        <prospect>
          <first_name>Jim</first_name>
          <last_name>Smith</last_name>
        </prospect>
      </rsp>)
    end
    
    it "should return the prospect" do
      fake_post "/api/prospect/version/3/do/create/email/user@test.com?format=simple&first_name=Jim", sample_results
      
      @client.prospects.create("user@test.com", :first_name => "Jim").should == {"last_name"=>"Smith", "first_name"=>"Jim"}
      assert_authorization_header
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-pardot-1.3.1 spec/pardot/objects/prospects_spec.rb
ruby-pardot-1.3.0 spec/pardot/objects/prospects_spec.rb