spec/creditsafe/client_spec.rb in creditsafe-0.3.0 vs spec/creditsafe/client_spec.rb in creditsafe-0.3.1
- old
+ new
@@ -6,12 +6,12 @@
URL = 'https://webservices.creditsafe.com/GlobalData/1.3/'\
'MainServiceBasic.svc'
RSpec.describe(Creditsafe::Client) do
notifications = []
- let(:username) { "b" }
- let(:password) { "c" }
+ let(:username) { "AzureDiamond" }
+ let(:password) { "hunter2" }
before(:all) do
ActiveSupport::Notifications.subscribe do |*args|
notifications << ActiveSupport::Notifications::Event.new(*args)
end
end
@@ -103,24 +103,24 @@
describe "#new" do
subject do
-> { described_class.new(username: username, password: password) }
end
- let(:username) { "foo" }
- let(:password) { "bar" }
it { is_expected.to_not raise_error }
context "without a username" do
let(:username) { nil }
it { is_expected.to raise_error(ArgumentError) }
end
+ end
- context "without a password" do
- let(:password) { nil }
- it { is_expected.to raise_error(ArgumentError) }
- end
+ describe "#inspect" do
+ let(:client) { described_class.new(username: username, password: password) }
+ subject { client.inspect }
+
+ it { is_expected.to_not include(password) }
end
describe '#find_company' do
let(:soap_verb) { 'find_companies' }
let(:client) { described_class.new(username: username, password: password) }
@@ -132,12 +132,14 @@
country_code: country_code,
registration_number: registration_number,
city: city
}.reject { |_, v| v.nil? }
end
- let(:find_company) { client.find_company(search_criteria) }
- let(:method_call) { find_company }
+
+ subject(:find_company) { client.find_company(search_criteria) }
+ subject(:method_call) { find_company }
+
before do
stub_request(:post, URL).to_return(
body: load_fixture('find-companies-successful.xml'),
status: 200
)
@@ -164,10 +166,21 @@
let(:country_code) { "DE" }
it { is_expected.to_not raise_error }
end
end
+ it 'requests the company deatils' do
+ find_company
+ expect(a_request(:post, URL).with do |req|
+ expect(CompareXML.equivalent?(
+ Nokogiri::XML(req.body),
+ load_xml_fixture('find-companies-request.xml'),
+ verbose: true
+ )).to eq([])
+ end).to have_been_made
+ end
+
it 'returns the company details' do
expect(find_company).
to eq(:name => 'GOCARDLESS LTD',
:type => 'Ltd',
:status => 'Active',
@@ -263,13 +276,24 @@
status: 200
)
end
let(:client) { described_class.new(username: username, password: password) }
let(:custom_data) { { foo: "bar", bar: "baz" } }
- let(:company_report) do
+ subject(:company_report) do
client.company_report('GB003/0/07495895', custom_data: custom_data)
end
- let(:method_call) { company_report }
+ subject(:method_call) { company_report }
+
+ it 'requests the company details' do
+ company_report
+ expect(a_request(:post, URL).with do |req|
+ expect(CompareXML.equivalent?(
+ Nokogiri::XML(req.body),
+ load_xml_fixture('company-report-request.xml'),
+ verbose: true
+ )).to eq([])
+ end).to have_been_made
+ end
it 'returns the company details' do
expect(company_report).to include(:company_summary)
end