Sha256: b6f94e9b6661b9b36c3bfe115b3ac1c68ddd87b8257be766c0201fda12c72b0a

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

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

describe Pardot::Objects::Opportunities do
  
  before do
    @client = create_client
  end
  
  describe "query" do
    
    def sample_results
      %(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
        <result>
          <total_results>2</total_results>
          <opportunity>
            <name>Jim</name>
            <type>Great</type>
          </opportunity>
          <opportunity>
            <name>Sue</name>
            <type>Good</type>
          </opportunity>
        </result>
      </rsp>)
    end
    
    before do
      @client = create_client
    end
    
    it "should take in some arguments" do
      fake_get "/api/opportunity/version/3/do/query?id_greater_than=200&format=simple", sample_results
      
      expect(@client.opportunities.query(:id_greater_than => 200)).to eq({"total_results" => 2, 
        "opportunity"=>[
          {"type"=>"Great", "name"=>"Jim"}, 
          {"type"=>"Good", "name"=>"Sue"}
        ]})
      assert_authorization_header
    end
    
  end
  
  describe "create_by_email" do
    
    def sample_results
      %(<?xml version="1.0" encoding="UTF-8"?>
      <rsp stat="ok" version="1.0">
        <opportunity>
          <name>Jim</name>
          <type>Good</type>
        </opportunity>
      </rsp>)
    end
    
    it "should return the prospect" do
      fake_post "/api/opportunity/version/3/do/create/prospect_email/user@test.com?type=Good&format=simple&name=Jim", sample_results
      
      expect(@client.opportunities.create_by_email("user@test.com", :name => "Jim", :type => "Good")).to eq({"name"=>"Jim", "type"=>"Good"})

      assert_authorization_header
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-pardot-1.3.2 spec/pardot/objects/opportunities_spec.rb