spec/leadsquared/lead_spec.rb in leadsquared-0.3.1 vs spec/leadsquared/lead_spec.rb in leadsquared-0.4.0
- old
+ new
@@ -4,10 +4,13 @@
let(:mock_connection) { double("connection") }
let(:lead_id) { "3131ea6a-bb20-4457-b183-ddf6d8716dfe" }
let(:email) { "test@example.com" }
let(:first_name) { "Bob" }
let(:last_name) { "Zeiger" }
+ let(:attributes) do
+ {"FirstName" => first_name, "LastName" => last_name}
+ end
let(:invalid_response_body) do
{
"Status" => "Error",
"ExceptionType" => "MXDuplicateEntryException",
@@ -217,37 +220,30 @@
{
"Attribute": "EmailAddress",
"Value": email
},
{
+ "Attribute": "SearchBy",
+ "Value": "EmailAddress"
+ },
+ {
"Attribute": "FirstName",
"Value": first_name
},
{
"Attribute": "LastName",
"Value": last_name
- },
- {
- "Attribute": "Phone",
- "Value": nil
- },
- {
- "Attribute": "SearchBy",
- "Value": "EmailAddress"
}
]
end
+
it "valid request" do
expect(mock_connection).to receive(:post).with(url, {}, body.to_json).and_return valid_response
- response = subject.create_or_update(email, first_name, last_name)
+ response = subject.create_or_update(email, attributes)
expect(response).to eq(success_response["Message"]["Id"])
end
end
-
- describe "search by phone" do
- pending "TODO"
- end
end
describe "#create_lead" do
let(:url) { "#{service}Lead.Create" }
let(:body) do
@@ -276,17 +272,17 @@
end
let(:valid_response) { double("response", status: 200, body: success_response.to_json) }
it "valid request with given params" do
expect(mock_connection).to receive(:post).with(url, {}, body.to_json).and_return valid_response
- response = subject.create_lead(email, first_name, last_name)
+ response = subject.create_lead(email, attributes)
expect(response).to eq(success_response["Message"]["Id"])
end
it "invalid request" do
expect(mock_connection).to receive(:post).with(url, {}, body.to_json).and_return invalid_response
expect {
- subject.create_lead(email, first_name, last_name)
+ subject.create_lead(email, attributes)
}.to raise_error(Leadsquared::InvalidRequestError)
end
end
describe "#get_meta_data" do