spec/rosetta_producer_spec.rb in libis-services-1.0.5 vs spec/rosetta_producer_spec.rb in libis-services-1.0.6
- old
+ new
@@ -1,8 +1,9 @@
# encoding: utf-8
require_relative 'spec_helper'
require 'yaml'
+require 'awesome_print'
require 'libis/tools/config_file'
require 'libis/services/rosetta/pds_handler'
require 'libis/services/rosetta/producer_handler'
@@ -41,12 +42,14 @@
before :each do
producer_handler.pds_handle = handle
end
context 'user info' do
+ # noinspection RubyBlockToMethodReference
let(:user_id) {admin_uid}
+ # noinspection RubyBlockToMethodReference
let(:user_name) {admin_usr}
it 'gets user id' do
result = producer_handler.user_id(user_name)
expect(result).to eq user_id
@@ -67,10 +70,11 @@
context 'producer' do
let(:producer_id) {credentials.producer.id}
let(:producer_data) {credentials.producer.data.to_hash}
+ # noinspection RubyArgCount
let(:producer_info) {::Libis::Services::Rosetta::Producer.new(producer_data).to_hash}
let(:updated_info) {{email: 'nomail@mail.com', telephone_2: '0032 16 32 22 22'}}
let(:new_producer_info) {
producer_data.merge(
authoritative_name: 'new test producer',
@@ -84,10 +88,11 @@
"#{$new_producer_id}"
end
it 'get producer' do
result = producer_handler.producer(producer_id)
+ # ap result
expect(result).not_to be_nil
expect(result.to_hash).to match producer_data
expect(producer_data).to match result.to_hash
end
@@ -134,23 +139,25 @@
first_name: 'Test',
last_name: 'Agent',
email_address: 'test@mail.com',
street: 'Willem de Croylaan 54',
city: 'Heverlee',
- zip: 3001,
+ zip: '3001',
country: 'Belgium',
telephone_1: '0032 16 32 22 66',
user_group: 'producer_agents'
}}
let(:new_agent) {
data = new_agent_data.dup
- data[:password] = data[:password_verify] = 'abc123ABC'
- Libis::Services::Rosetta::User.new(data).to_hash
+ # data[:password] = data[:password_verify] = 'abc123ABC'
+ # noinspection RubyArgCount
+ Libis::Services::Rosetta::ProducerAgent.new(data).to_hash
}
# noinspection RubyResolve
let(:agent_data) {credentials.producer_agent.data.to_hash}
+ # noinspection RubyArgCount
let(:agent) {::Libis::Services::Rosetta::User.new(agent_data)}
# noinspection RubyResolve
let(:agent_id) {credentials.producer_agent.user_id}
# noinspection RubyResolve
let(:agent_ins) {credentials.producer_agent.institute}
@@ -161,11 +168,13 @@
end
it 'get info' do
result = producer_handler.agent(agent_id)
expect(result).not_to be_nil
- expect(result.to_hash).to include agent_data
+ # ap result.to_hash
+ # ap agent_data
+ expect(result.to_hash).to match agent_data
end
it 'create' do
result = producer_handler.new_agent new_agent
expect(result).not_to be_nil
@@ -174,11 +183,11 @@
end
it 'get info' do
result = producer_handler.agent(new_agent_id)
expect(result).not_to be_nil
- expect(result.to_hash).to include new_agent_data
+ expect(result.to_hash).to match new_agent_data
end
it 'update info' do
# update data
updated_agent = new_agent_data.dup
@@ -203,19 +212,21 @@
end
it 'get producers' do
result = producer_handler.agent_producers agent_id, agent_ins
expect(result).not_to be_nil
+ # noinspection RubyResolve
expect(result).to eq [{id: credentials.producer.id, description: credentials.producer.data.authoritative_name}]
end
end
context 'contact' do
let(:contact_id) {credentials.contact.user_id}
let(:contact_info) {credentials.contact.data.to_hash}
let(:new_contact) {
+ # noinspection RubyArgCount
::Libis::Services::Rosetta::User.new(
first_name: 'New',
last_name: 'Contact',
language: 'English',
status: 'ACTIVE',
\ No newline at end of file