spec/concerns/import_leads_spec.rb in mrkt-1.2.0 vs spec/concerns/import_leads_spec.rb in mrkt-1.2.1
- old
+ new
@@ -1,12 +1,14 @@
require 'csv'
require 'tempfile'
describe Mrkt::ImportLeads do
- include_context 'initialized client'
+ include_context 'with an initialized client'
describe '#import_lead' do
+ subject { client.import_lead(tempfile) }
+
let(:tempfile) { Tempfile.new(%w[import-leads csv]) }
let(:response_stub) do
{
requestId: 'c245#14cd6830ae2',
success: true,
@@ -16,11 +18,10 @@
status: 'Importing'
}
]
}
end
- subject { client.import_lead(tempfile) }
before do
CSV.open(tempfile, 'wb') do |csv|
csv << %w[email firstName lastName]
csv << %w[sample@example.com John Snow]
@@ -37,10 +38,12 @@
it { is_expected.to eq(response_stub) }
end
describe '#import_lead_status' do
+ subject { client.import_lead_status(1) }
+
let(:id) { 1 }
let(:response_stub) do
{
requestId: 'c245#14cd6830ae2',
result: [
@@ -54,36 +57,37 @@
}
],
success: true
}
end
- subject { client.import_lead_status(1) }
before do
stub_request(:get, "https://#{host}/bulk/v1/leads/batch/#{id}.json")
.to_return(json_stub(response_stub))
end
it { is_expected.to eq(response_stub) }
end
describe '#import_lead_failures' do
+ subject { client.import_lead_failures(1) }
+
let(:id) { 1 }
let(:response_stub) { '' }
- subject { client.import_lead_failures(1) }
before do
stub_request(:get, "https://#{host}/bulk/v1/leads/batch/#{id}/failures.json")
.to_return(headers: { content_length: 0 })
end
it { is_expected.to eq(response_stub) }
end
describe '#import_lead_warnings' do
+ subject { client.import_lead_warnings(1) }
+
let(:id) { 1 }
let(:response_stub) { '' }
- subject { client.import_lead_warnings(1) }
before do
stub_request(:get, "https://#{host}/bulk/v1/leads/batch/#{id}/warnings.json")
.to_return(headers: { content_length: 0 })
end