Skip to content

Commit

Permalink
[W-7879842] Update httparty and rspec versions (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Pearson authored Aug 19, 2020
1 parent d1f2859 commit 8de6325
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 80 deletions.
37 changes: 22 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,35 @@ PATH
specs:
ruby-pardot (1.3.2)
crack (= 0.4.3)
httparty (= 0.13.1)
httparty (= 0.18.1)

GEM
remote: http://rubygems.org/
specs:
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.1.2)
diff-lcs (1.4.4)
fakeweb (1.3.0)
httparty (0.13.1)
json (~> 1.8)
httparty (0.18.1)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
json (1.8.6)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
multi_xml (0.6.0)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
safe_yaml (1.0.5)

PLATFORMS
Expand All @@ -33,8 +40,8 @@ PLATFORMS
DEPENDENCIES
bundler (>= 1.10)
fakeweb
rspec
rspec (= 3.5.0)
ruby-pardot!

BUNDLED WITH
2.0.2
2.1.4
2 changes: 2 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Add the following to your Gemfile

The client will authenticate before performing other API calls, but you can manually authenticate as well

require "ruby-pardot"

client = Pardot::Client.new email, password, user_key

# will raise a Pardot::ResponseError if login fails
Expand Down
4 changes: 2 additions & 2 deletions ruby-pardot.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Gem::Specification.new do |s|
s.rubyforge_project = "ruby-pardot"

s.add_dependency "crack", "0.4.3"
s.add_dependency "httparty", "0.13.1"
s.add_dependency "httparty", "0.18.1"

s.add_development_dependency "bundler", ">= 1.10"
s.add_development_dependency "rspec"
s.add_development_dependency "rspec", "3.5.0"
s.add_development_dependency "fakeweb"

s.files = `git ls-files`.split("\n")
Expand Down
20 changes: 10 additions & 10 deletions spec/pardot/authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ def authenticate
end

def verifyBody
FakeWeb.last_request.body.should == 'email=user%40test.com&password=foo&user_key=bar'
expect(FakeWeb.last_request.body).to eq('email=user%40test.com&password=foo&user_key=bar')
end

it "should return the api key" do
authenticate.should == "my_api_key"
expect(authenticate).to eq("my_api_key")
end

it "should set the api key" do
authenticate
@client.api_key.should == "my_api_key"
expect(@client.api_key).to eq("my_api_key")
verifyBody
end

it "should make authenticated? true" do
authenticate
@client.authenticated?.should == true
expect(@client.authenticated?).to eq(true)
verifyBody
end

it "should use version 3" do
authenticate
@client.version.to_i.should == 3
expect(@client.version.to_i).to eq(3)
verifyBody
end

Expand All @@ -61,28 +61,28 @@ def authenticate
end

def verifyBody
FakeWeb.last_request.body.should == 'email=user%40test.com&password=foo&user_key=bar'
expect(FakeWeb.last_request.body).to eq('email=user%40test.com&password=foo&user_key=bar')
end

it "should return the api key" do
authenticate.should == "my_api_key"
expect(authenticate).to eq("my_api_key")
end

it "should set the api key" do
authenticate
@client.api_key.should == "my_api_key"
expect(@client.api_key).to eq("my_api_key")
verifyBody
end

it "should make authenticated? true" do
authenticate
@client.authenticated?.should == true
expect(@client.authenticated?).to eq(true)
verifyBody
end

it "should use version 4" do
authenticate
@client.version.to_i.should == 4
expect(@client.version.to_i).to eq(4)
verifyBody
end

Expand Down
12 changes: 6 additions & 6 deletions spec/pardot/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ def create_client

describe "client" do
after do
@client.email.should == "[email protected]"
@client.password.should == "password"
@client.user_key.should == "user_key"
@client.format.should == "simple"
expect(@client.email).to eq("[email protected]")
expect(@client.password).to eq("password")
expect(@client.user_key).to eq("user_key")
expect(@client.format).to eq("simple")
end

it "should set variables without version" do
@client = Pardot::Client.new "[email protected]", "password", "user_key"
@client.version.should == 3
expect(@client.version).to eq(3)
end

it "should set variables with version" do
@client = Pardot::Client.new "[email protected]", "password", "user_key", 4
@client.version.should == 4
expect(@client.version).to eq(4)
end

end
Expand Down
4 changes: 2 additions & 2 deletions spec/pardot/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
described_class.new(@res)
end
specify do
subject.to_s.should == @res["__content__"]
expect(subject.to_s).to eq(@res["__content__"])
end
specify do
subject.message.should == @res["__content__"]
expect(subject.message).to eq(@res["__content__"])
end
end

Expand Down
33 changes: 17 additions & 16 deletions spec/pardot/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ def get object = "foo", path = "/bar", params = {}
fake_get "/api/foo/version/3/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)

lambda { get }.should raise_error(Pardot::ResponseError)

expect(lambda { get }).to raise_error(Pardot::ResponseError)
end

it "should catch and reraise SocketErrors as Pardot::NetError" do
Pardot::Client.should_receive(:get).and_raise(SocketError)
expect(Pardot::Client).to receive(:get).and_raise(SocketError)

lambda { get }.should raise_error(Pardot::NetError)
expect(lambda { get }).to raise_error(Pardot::NetError)
end

it "should call handle_expired_api_key when the api key expires" do
fake_get "/api/foo/version/3/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)

@client.should_receive(:handle_expired_api_key)
expect(@client).to receive(:handle_expired_api_key)
get
end

Expand All @@ -50,20 +51,20 @@ def post object = "foo", path = "/bar", params = {}
fake_post "/api/foo/version/3/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)

lambda { post }.should raise_error(Pardot::ResponseError)
expect(lambda { post }).to raise_error(Pardot::ResponseError)
end

it "should catch and reraise SocketErrors as Pardot::NetError" do
Pardot::Client.should_receive(:post).and_raise(SocketError)
expect(Pardot::Client).to receive(:post).and_raise(SocketError)

lambda { post }.should raise_error(Pardot::NetError)
expect(lambda { post }).to raise_error(Pardot::NetError)
end

it "should call handle_expired_api_key when the api key expires" do
fake_post "/api/foo/version/3/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)

@client.should_receive(:handle_expired_api_key)
expect(@client).to receive(:handle_expired_api_key)
post
end

Expand All @@ -80,20 +81,20 @@ def get object = "foo", path = "/bar", params = {}
fake_get "/api/foo/version/4/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)

lambda { get }.should raise_error(Pardot::ResponseError)
expect(lambda { get }).to raise_error(Pardot::ResponseError)
end

it "should catch and reraise SocketErrors as Pardot::NetError" do
Pardot::Client.should_receive(:get).and_raise(SocketError)
expect(Pardot::Client).to receive(:get).and_raise(SocketError)

lambda { get }.should raise_error(Pardot::NetError)
expect(lambda { get }).to raise_error(Pardot::NetError)
end

it "should call handle_expired_api_key when the api key expires" do
fake_get "/api/foo/version/4/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)

@client.should_receive(:handle_expired_api_key)
expect(@client).to receive(:handle_expired_api_key)
get
end

Expand All @@ -110,20 +111,20 @@ def post object = "foo", path = "/bar", params = {}
fake_post "/api/foo/version/4/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)

lambda { post }.should raise_error(Pardot::ResponseError)
expect(lambda { post }).to raise_error(Pardot::ResponseError)
end

it "should catch and reraise SocketErrors as Pardot::NetError" do
Pardot::Client.should_receive(:post).and_raise(SocketError)
expect(Pardot::Client).to receive(:post).and_raise(SocketError)

lambda { post }.should raise_error(Pardot::NetError)
expect(lambda { post }).to raise_error(Pardot::NetError)
end

it "should call handle_expired_api_key when the api key expires" do
fake_post "/api/foo/version/4/bar?format=simple",
%(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)

@client.should_receive(:handle_expired_api_key)
expect(@client).to receive(:handle_expired_api_key)
post
end

Expand Down
4 changes: 2 additions & 2 deletions spec/pardot/objects/custom_fields_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def sample_results
it "should take in some arguments" do
fake_get "/api/customField/version/3/do/query?id_greater_than=200&format=simple", sample_results

@client.custom_fields.query(:id_greater_than => 200).should == {"total_results" => 1,
expect(@client.custom_fields.query(:id_greater_than => 200)).to eq({"total_results" => 1,
"customField"=>
{
"id"=>"8932",
Expand All @@ -49,7 +49,7 @@ def sample_results
"created_at"=>"2019-11-26 13:40:37",
"updated_at"=>"2019-11-26 13:40:37"
}
}
})
assert_authorization_header
end

Expand Down
6 changes: 3 additions & 3 deletions spec/pardot/objects/emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def sample_response

it "should take in the email ID" do
fake_get "/api/email/version/3/do/read/id/12?format=simple", sample_response
@client.emails.read_by_id(12).should == {"name" => "My Email"}
expect(@client.emails.read_by_id(12)).to eq({"name" => "My Email"})
assert_authorization_header
end

it 'should send to a prospect' do
fake_post '/api/email/version/3/do/send/prospect_id/42?campaign_id=765&email_template_id=86&format=simple', sample_response
@client.emails.send_to_prospect(42, :campaign_id => 765, :email_template_id => 86).should == {"name" => "My Email"}
expect(@client.emails.send_to_prospect(42, :campaign_id => 765, :email_template_id => 86)).to eq({"name" => "My Email"})
assert_authorization_header
end

it 'should send to a list' do
fake_post '/api/email/version/3/do/send?email_template_id=200&list_ids[]=235&campaign_id=654&format=simple', sample_response
@client.emails.send_to_list(:email_template_id => 200, 'list_ids[]' => 235, :campaign_id => 654).should == {"name" => "My Email"}
expect(@client.emails.send_to_list(:email_template_id => 200, 'list_ids[]' => 235, :campaign_id => 654)).to eq({"name" => "My Email"})
assert_authorization_header
end

Expand Down
4 changes: 2 additions & 2 deletions spec/pardot/objects/lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def sample_results
it "should take in some arguments" do
fake_get "/api/list/version/3/do/query?id_greater_than=200&format=simple", sample_results

@client.lists.query(:id_greater_than => 200).should == {"total_results" => 2,
expect(@client.lists.query(:id_greater_than => 200)).to eq({"total_results" => 2,
"list"=>[
{"name"=>"Asdf List"},
{"name"=>"Qwerty List"}
]}
]})
assert_authorization_header
end

Expand Down
6 changes: 3 additions & 3 deletions spec/pardot/objects/opportunities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def sample_results
it "should take in some arguments" do
fake_get "/api/opportunity/version/3/do/query?id_greater_than=200&format=simple", sample_results

@client.opportunities.query(:id_greater_than => 200).should == {"total_results" => 2,
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

Expand All @@ -56,7 +56,7 @@ def sample_results
it "should return the prospect" do
fake_post "/api/opportunity/version/3/do/create/prospect_email/[email protected]?type=Good&format=simple&name=Jim", sample_results

@client.opportunities.create_by_email("[email protected]", :name => "Jim", :type => "Good").should == {"name"=>"Jim", "type"=>"Good"}
expect(@client.opportunities.create_by_email("[email protected]", :name => "Jim", :type => "Good")).to eq({"name"=>"Jim", "type"=>"Good"})

assert_authorization_header
end
Expand Down
Loading

0 comments on commit 8de6325

Please sign in to comment.