amorail 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.hound.yml +10 -0
- data/.rubocop.yml +14 -0
- data/lib/amorail/client.rb +33 -28
- data/lib/amorail/config.rb +7 -1
- data/lib/amorail/engine.rb +2 -1
- data/lib/amorail/entities/company.rb +3 -0
- data/lib/amorail/entities/contact.rb +5 -2
- data/lib/amorail/entities/lead.rb +1 -0
- data/lib/amorail/entities/leadable.rb +6 -0
- data/lib/amorail/entities/task.rb +1 -15
- data/lib/amorail/entity/finders.rb +30 -0
- data/lib/amorail/entity/params.rb +95 -0
- data/lib/amorail/entity/persistance.rb +47 -0
- data/lib/amorail/entity.rb +23 -172
- data/lib/amorail/exceptions.rb +3 -4
- data/lib/amorail/{custom_fields.rb → property.rb} +24 -21
- data/lib/amorail/version.rb +2 -1
- data/lib/amorail.rb +3 -3
- data/lib/tasks/amorail.rake +3 -3
- data/spec/client_spec.rb +1 -1
- data/spec/company_spec.rb +22 -5
- data/spec/contact_spec.rb +28 -10
- data/spec/entity_spec.rb +11 -7
- data/spec/helpers/webmock_helpers.rb +85 -53
- data/spec/lead_spec.rb +19 -3
- data/spec/{custom_class_spec.rb → property_spec.rb} +5 -5
- data/spec/spec_helper.rb +4 -2
- data/spec/support/entity_class_example.rb +15 -0
- data/spec/task_spec.rb +25 -6
- metadata +11 -5
data/lib/amorail/exceptions.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# Amorail Exceptions.
|
2
2
|
# Every class is name of HTTP response error code(status)
|
3
|
-
|
4
3
|
module Amorail
|
5
4
|
class Error < ::StandardError; end
|
6
5
|
|
7
6
|
class APIError < Error; end
|
8
|
-
|
7
|
+
|
9
8
|
class AmoBadRequestError < APIError; end
|
10
9
|
|
11
10
|
class AmoMovedPermanentlyError < APIError; end
|
@@ -23,4 +22,4 @@ module Amorail
|
|
23
22
|
class AmoServiceUnaviableError < APIError; end
|
24
23
|
|
25
24
|
class AmoUnknownError < APIError; end
|
26
|
-
end
|
25
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Amorail
|
2
|
-
|
2
|
+
# Return hash key as method call
|
3
3
|
module MethodMissing
|
4
4
|
def method_missing(method_sym, *arguments, &block)
|
5
|
-
if data.
|
5
|
+
if data.key?(method_sym.to_s)
|
6
6
|
data.fetch(method_sym.to_s)
|
7
7
|
else
|
8
8
|
super
|
@@ -10,10 +10,22 @@ module Amorail
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
class Property
|
13
|
+
class Property # :nodoc: all
|
14
14
|
class PropertyItem
|
15
15
|
include MethodMissing
|
16
16
|
|
17
|
+
class << self
|
18
|
+
attr_accessor :source_name
|
19
|
+
|
20
|
+
def parse(data)
|
21
|
+
hash = {}
|
22
|
+
data['custom_fields'][source_name].each do |contact|
|
23
|
+
hash[contact['code'].downcase] = PropertyItem.new(contact)
|
24
|
+
end
|
25
|
+
new hash
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
17
29
|
attr_reader :data
|
18
30
|
|
19
31
|
def initialize(data)
|
@@ -32,7 +44,7 @@ module Amorail
|
|
32
44
|
@statuses = data
|
33
45
|
end
|
34
46
|
end
|
35
|
-
|
47
|
+
|
36
48
|
attr_reader :client, :data, :contacts,
|
37
49
|
:company, :leads, :tasks
|
38
50
|
|
@@ -45,9 +57,12 @@ module Amorail
|
|
45
57
|
@data = load_fields
|
46
58
|
parse_all_data
|
47
59
|
end
|
48
|
-
|
60
|
+
|
49
61
|
def load_fields
|
50
|
-
response = client.safe_request(
|
62
|
+
response = client.safe_request(
|
63
|
+
:get,
|
64
|
+
'/private/api/v2/json/accounts/current'
|
65
|
+
)
|
51
66
|
response.body["response"]["account"]
|
52
67
|
end
|
53
68
|
|
@@ -65,23 +80,11 @@ module Amorail
|
|
65
80
|
end
|
66
81
|
|
67
82
|
class Contact < PropertyItem
|
68
|
-
|
69
|
-
hash = {}
|
70
|
-
data['custom_fields']['contacts'].each do |contact|
|
71
|
-
hash[contact['code'].downcase] = PropertyItem.new(contact)
|
72
|
-
end
|
73
|
-
new hash
|
74
|
-
end
|
83
|
+
self.source_name = 'contacts'
|
75
84
|
end
|
76
85
|
|
77
86
|
class Company < PropertyItem
|
78
|
-
|
79
|
-
hash = {}
|
80
|
-
data['custom_fields']['companies'].each do |company|
|
81
|
-
hash[company['code'].downcase] = PropertyItem.new(company)
|
82
|
-
end
|
83
|
-
new hash
|
84
|
-
end
|
87
|
+
self.source_name = 'companies'
|
85
88
|
end
|
86
89
|
|
87
90
|
class Lead < StatusItem
|
@@ -106,4 +109,4 @@ module Amorail
|
|
106
109
|
end
|
107
110
|
end
|
108
111
|
end
|
109
|
-
end
|
112
|
+
end
|
data/lib/amorail/version.rb
CHANGED
data/lib/amorail.rb
CHANGED
@@ -3,12 +3,12 @@ require 'amorail/config'
|
|
3
3
|
require 'amorail/client'
|
4
4
|
require 'amorail/exceptions'
|
5
5
|
require 'amorail/entity'
|
6
|
-
require 'amorail/
|
7
|
-
|
8
|
-
require 'amorail/entities/leadable'
|
6
|
+
require 'amorail/property'
|
9
7
|
|
10
8
|
Gem.find_files('amorail/entities/*.rb').each { |path| require path }
|
11
9
|
|
10
|
+
# AmoCRM API integration.
|
11
|
+
# https://www.amocrm.com/
|
12
12
|
module Amorail
|
13
13
|
def self.config
|
14
14
|
@config ||= Config.new
|
data/lib/tasks/amorail.rake
CHANGED
data/spec/client_spec.rb
CHANGED
data/spec/company_spec.rb
CHANGED
@@ -2,14 +2,28 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Amorail::AmoCompany do
|
4
4
|
before { mock_api }
|
5
|
-
|
5
|
+
|
6
6
|
describe "validations" do
|
7
7
|
it { should validate_presence_of(:name) }
|
8
8
|
end
|
9
9
|
|
10
|
+
describe ".attributes" do
|
11
|
+
subject { described_class.attributes }
|
12
|
+
|
13
|
+
it_behaves_like 'entity_class'
|
14
|
+
|
15
|
+
specify { is_expected.to include(:name) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".properties" do
|
19
|
+
subject { described_class.properties }
|
20
|
+
|
21
|
+
specify { is_expected.to include(:email, :phone, :web, :address) }
|
22
|
+
end
|
23
|
+
|
10
24
|
describe "#params" do
|
11
25
|
let(:company) do
|
12
|
-
|
26
|
+
described_class.new(
|
13
27
|
name: 'Test inc',
|
14
28
|
phone: '12345678',
|
15
29
|
email: 'test@mala.ru',
|
@@ -20,6 +34,7 @@ describe Amorail::AmoCompany do
|
|
20
34
|
|
21
35
|
subject { company.params }
|
22
36
|
|
37
|
+
specify { is_expected.to include(:last_modified) }
|
23
38
|
specify { is_expected.to include(name: 'Test inc') }
|
24
39
|
specify { is_expected.to include(type: 'contact') }
|
25
40
|
|
@@ -27,14 +42,16 @@ describe Amorail::AmoCompany do
|
|
27
42
|
prop = subject[:custom_fields].detect { |p| p[:id] == "1460591" }
|
28
43
|
expect(prop).not_to be_nil
|
29
44
|
expect(prop[:values].first[:value]).to eq 'test@mala.ru'
|
30
|
-
expect(prop[:values].first[:enum])
|
45
|
+
expect(prop[:values].first[:enum])
|
46
|
+
.to eq described_class.properties[:email][:enum]
|
31
47
|
end
|
32
48
|
|
33
49
|
it "contains phone property" do
|
34
50
|
prop = subject[:custom_fields].detect { |p| p[:id] == "1460589" }
|
35
51
|
expect(prop).not_to be_nil
|
36
52
|
expect(prop[:values].first[:value]).to eq '12345678'
|
37
|
-
expect(prop[:values].first[:enum])
|
53
|
+
expect(prop[:values].first[:enum])
|
54
|
+
.to eq described_class.properties[:phone][:enum]
|
38
55
|
end
|
39
56
|
|
40
57
|
it "contains address property" do
|
@@ -51,7 +68,7 @@ describe Amorail::AmoCompany do
|
|
51
68
|
end
|
52
69
|
|
53
70
|
describe "#save" do
|
54
|
-
let(:company) {
|
71
|
+
let(:company) { described_class.new(name: "test") }
|
55
72
|
|
56
73
|
before { company_create_stub(Amorail.config.api_endpoint) }
|
57
74
|
|
data/spec/contact_spec.rb
CHANGED
@@ -3,15 +3,29 @@ require "spec_helper"
|
|
3
3
|
describe Amorail::AmoContact do
|
4
4
|
before { mock_api }
|
5
5
|
|
6
|
-
let(:contact) {
|
6
|
+
let(:contact) { described_class.new(name: "test") }
|
7
7
|
|
8
8
|
describe "validations" do
|
9
|
-
it { should validate_presence_of(:name)}
|
9
|
+
it { should validate_presence_of(:name) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".attributes" do
|
13
|
+
subject { described_class.attributes }
|
14
|
+
|
15
|
+
it_behaves_like 'entity_class'
|
16
|
+
|
17
|
+
specify { is_expected.to include(:name, :company_name) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".properties" do
|
21
|
+
subject { described_class.properties }
|
22
|
+
|
23
|
+
specify { is_expected.to include(:email, :phone, :position) }
|
10
24
|
end
|
11
25
|
|
12
26
|
describe "#params" do
|
13
27
|
let(:contact) do
|
14
|
-
|
28
|
+
described_class.new(
|
15
29
|
name: 'Tester',
|
16
30
|
company_name: 'Test inc',
|
17
31
|
phone: '12345678',
|
@@ -22,6 +36,7 @@ describe Amorail::AmoContact do
|
|
22
36
|
|
23
37
|
subject { contact.params }
|
24
38
|
|
39
|
+
specify { is_expected.to include(:last_modified) }
|
25
40
|
specify { is_expected.to include(name: 'Tester') }
|
26
41
|
specify { is_expected.to include(company_name: 'Test inc') }
|
27
42
|
|
@@ -29,14 +44,16 @@ describe Amorail::AmoContact do
|
|
29
44
|
prop = subject[:custom_fields].detect { |p| p[:id] == "1460591" }
|
30
45
|
expect(prop).not_to be_nil
|
31
46
|
expect(prop[:values].first[:value]).to eq 'test@mala.ru'
|
32
|
-
expect(prop[:values].first[:enum])
|
47
|
+
expect(prop[:values].first[:enum])
|
48
|
+
.to eq described_class.properties[:email][:enum]
|
33
49
|
end
|
34
50
|
|
35
51
|
it "contains phone property" do
|
36
52
|
prop = subject[:custom_fields].detect { |p| p[:id] == "1460589" }
|
37
53
|
expect(prop).not_to be_nil
|
38
54
|
expect(prop[:values].first[:value]).to eq '12345678'
|
39
|
-
expect(prop[:values].first[:enum])
|
55
|
+
expect(prop[:values].first[:enum])
|
56
|
+
.to eq described_class.properties[:phone][:enum]
|
40
57
|
end
|
41
58
|
|
42
59
|
it "contains position property" do
|
@@ -51,20 +68,21 @@ describe Amorail::AmoContact do
|
|
51
68
|
before { contact_find_stub(Amorail.config.api_endpoint, 102, false) }
|
52
69
|
|
53
70
|
it "loads entity" do
|
54
|
-
obj =
|
71
|
+
obj = described_class.find(101)
|
55
72
|
expect(obj.id).to eq 101
|
56
73
|
expect(obj.company_name).to eq "Foo Inc."
|
57
74
|
expect(obj.email).to eq "foo@tb.com"
|
58
75
|
expect(obj.phone).to eq "1111 111 111"
|
76
|
+
expect(obj.params[:id]).to eq 101
|
59
77
|
end
|
60
78
|
|
61
79
|
it "returns nil" do
|
62
|
-
obj =
|
80
|
+
obj = described_class.find(102)
|
63
81
|
expect(obj).to be_falsey
|
64
82
|
end
|
65
83
|
|
66
84
|
it "raise error" do
|
67
|
-
expect {
|
85
|
+
expect { described_class.find!(102) }
|
68
86
|
.to raise_error(Amorail::AmoEntity::RecordNotFound)
|
69
87
|
end
|
70
88
|
end
|
@@ -91,12 +109,12 @@ describe Amorail::AmoContact do
|
|
91
109
|
end
|
92
110
|
|
93
111
|
it "raise error if id is blank?" do
|
94
|
-
obj =
|
112
|
+
obj = described_class.new
|
95
113
|
expect { obj.update!(name: 'Igor') }.to raise_error
|
96
114
|
end
|
97
115
|
|
98
116
|
it "raise error" do
|
99
|
-
obj =
|
117
|
+
obj = described_class.new
|
100
118
|
expect { obj.update!(id: 101, name: "Igor") }
|
101
119
|
.to(raise_error)
|
102
120
|
end
|
data/spec/entity_spec.rb
CHANGED
@@ -3,7 +3,9 @@ require "spec_helper"
|
|
3
3
|
describe Amorail::AmoEntity do
|
4
4
|
before { mock_api }
|
5
5
|
|
6
|
-
let(:entity) {
|
6
|
+
let(:entity) { described_class.new }
|
7
|
+
|
8
|
+
it_behaves_like 'entity_class'
|
7
9
|
|
8
10
|
describe "#params" do
|
9
11
|
let(:now) { Time.now }
|
@@ -11,13 +13,14 @@ describe Amorail::AmoEntity do
|
|
11
13
|
subject { entity.params }
|
12
14
|
|
13
15
|
specify { is_expected.to include(:last_modified) }
|
14
|
-
specify {
|
15
|
-
|
16
|
+
specify {
|
17
|
+
is_expected.not_to include(
|
18
|
+
:id, :request_id, :responsible_user_id, :date_create)
|
16
19
|
}
|
17
20
|
|
18
21
|
context "with some values" do
|
19
22
|
let(:entity) do
|
20
|
-
|
23
|
+
described_class.new(
|
21
24
|
responsible_user_id: 2,
|
22
25
|
last_modified: now
|
23
26
|
)
|
@@ -25,14 +28,15 @@ describe Amorail::AmoEntity do
|
|
25
28
|
|
26
29
|
specify { is_expected.to include(responsible_user_id: 2) }
|
27
30
|
specify { is_expected.to include(last_modified: now.to_i) }
|
28
|
-
specify {
|
29
|
-
|
31
|
+
specify {
|
32
|
+
is_expected.not_to include(
|
33
|
+
:id, :request_id, :date_create)
|
30
34
|
}
|
31
35
|
end
|
32
36
|
|
33
37
|
context "with all values" do
|
34
38
|
let(:entity) do
|
35
|
-
|
39
|
+
described_class.new(
|
36
40
|
id: 100,
|
37
41
|
request_id: 1,
|
38
42
|
responsible_user_id: 2,
|
@@ -1,64 +1,96 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module AmoWebMock
|
2
|
+
def mock_api
|
3
|
+
authorize_stub(
|
4
|
+
Amorail.config.api_endpoint,
|
5
|
+
Amorail.config.usermail,
|
6
|
+
Amorail.config.api_key)
|
5
7
|
|
6
|
-
|
7
|
-
end
|
8
|
+
account_info_stub(Amorail.config.api_endpoint)
|
9
|
+
end
|
8
10
|
|
9
|
-
def authorize_stub(endpoint, usermail, api_key)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def authorize_stub(endpoint, usermail, api_key)
|
12
|
+
cookie = 'PHPSESSID=58vorte6dd4t7h6mtuig9l0p50; path=/; domain=amocrm.ru'
|
13
|
+
stub_request(:post, "#{endpoint}/private/api/auth.php?type=json")
|
14
|
+
.with(
|
15
|
+
body: "{\"USER_LOGIN\":\"#{usermail}\",\"USER_HASH\":\"#{api_key}\"}"
|
16
|
+
)
|
17
|
+
.to_return(
|
18
|
+
status: 200,
|
19
|
+
body: "",
|
20
|
+
headers: {
|
21
|
+
'Set-Cookie' => cookie
|
22
|
+
})
|
23
|
+
end
|
15
24
|
|
16
|
-
def account_info_stub(endpoint)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
def account_info_stub(endpoint)
|
26
|
+
stub_request(:get, endpoint + '/private/api/v2/json/accounts/current')
|
27
|
+
.to_return(
|
28
|
+
body: File.read('./spec/fixtures/account_response.json'),
|
29
|
+
headers: { 'Content-Type' => 'application/json' },
|
30
|
+
status: 200
|
31
|
+
)
|
32
|
+
end
|
21
33
|
|
22
|
-
def unauthorized_account_info_stub(endpoint)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
34
|
+
def unauthorized_account_info_stub(endpoint)
|
35
|
+
stub_request(:get, endpoint + '/private/api/v2/json/accounts/current')
|
36
|
+
.to_return(
|
37
|
+
body: "", status: 401
|
38
|
+
)
|
39
|
+
end
|
27
40
|
|
28
|
-
def bad_req_account_info_stub(endpoint)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
def bad_req_account_info_stub(endpoint)
|
42
|
+
stub_request(:post, endpoint + '/private/api/v2/json/accounts/current')
|
43
|
+
.with(body: "{}")
|
44
|
+
.to_return(
|
45
|
+
body: "",
|
46
|
+
status: 400
|
47
|
+
)
|
48
|
+
end
|
34
49
|
|
35
|
-
def contact_create_stub(endpoint)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
50
|
+
def contact_create_stub(endpoint)
|
51
|
+
stub_request(:post, endpoint + '/private/api/v2/json/contacts/set')
|
52
|
+
.to_return(
|
53
|
+
body: File.read('./spec/fixtures/contact_create.json'),
|
54
|
+
headers: { 'Content-Type' => 'application/json' },
|
55
|
+
status: 200
|
56
|
+
)
|
57
|
+
end
|
41
58
|
|
42
|
-
def contact_update_stub(endpoint)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
59
|
+
def contact_update_stub(endpoint)
|
60
|
+
stub_request(:post, endpoint + '/private/api/v2/json/contacts/set')
|
61
|
+
.to_return(
|
62
|
+
body: File.read('./spec/fixtures/contact_update.json'),
|
63
|
+
headers: {
|
64
|
+
'Content-Type' => 'application/json'
|
65
|
+
},
|
66
|
+
status: 200
|
67
|
+
)
|
68
|
+
end
|
48
69
|
|
49
|
-
def contact_find_stub(endpoint, id, success = true)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
70
|
+
def contact_find_stub(endpoint, id, success = true)
|
71
|
+
if success
|
72
|
+
stub_request(
|
73
|
+
:get,
|
74
|
+
"#{endpoint}/private/api/v2/json/contacts/list?id=#{id}")
|
75
|
+
.to_return(
|
76
|
+
body: File.read('./spec/fixtures/contact_find.json'),
|
77
|
+
headers: { 'Content-Type' => 'application/json' },
|
78
|
+
status: 200
|
79
|
+
)
|
80
|
+
else
|
81
|
+
stub_request(
|
82
|
+
:get,
|
83
|
+
"#{endpoint}/private/api/v2/json/contacts/list?id=#{id}")
|
84
|
+
.to_return(body: nil, status: 204)
|
85
|
+
end
|
56
86
|
end
|
57
|
-
end
|
58
87
|
|
59
|
-
def company_create_stub(endpoint)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
88
|
+
def company_create_stub(endpoint)
|
89
|
+
stub_request(:post, endpoint + '/private/api/v2/json/company/set')
|
90
|
+
.to_return(
|
91
|
+
body: File.read('./spec/fixtures/contact_create.json'),
|
92
|
+
headers: { 'Content-Type' => 'application/json' },
|
93
|
+
status: 200
|
94
|
+
)
|
95
|
+
end
|
64
96
|
end
|
data/spec/lead_spec.rb
CHANGED
@@ -4,13 +4,28 @@ describe Amorail::AmoLead do
|
|
4
4
|
before { mock_api }
|
5
5
|
|
6
6
|
describe "validations" do
|
7
|
-
it { should validate_presence_of(:name)}
|
8
|
-
it { should validate_presence_of(:status_id)}
|
7
|
+
it { should validate_presence_of(:name) }
|
8
|
+
it { should validate_presence_of(:status_id) }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".attributes" do
|
12
|
+
subject { described_class.attributes }
|
13
|
+
|
14
|
+
it_behaves_like 'entity_class'
|
15
|
+
|
16
|
+
specify do
|
17
|
+
is_expected.to include(
|
18
|
+
:name,
|
19
|
+
:price,
|
20
|
+
:status_id,
|
21
|
+
:tags
|
22
|
+
)
|
23
|
+
end
|
9
24
|
end
|
10
25
|
|
11
26
|
describe "#params" do
|
12
27
|
let(:lead) do
|
13
|
-
|
28
|
+
described_class.new(
|
14
29
|
name: 'Test',
|
15
30
|
price: 100,
|
16
31
|
status_id: 2,
|
@@ -20,6 +35,7 @@ describe Amorail::AmoLead do
|
|
20
35
|
|
21
36
|
subject { lead.params }
|
22
37
|
|
38
|
+
specify { is_expected.to include(:last_modified) }
|
23
39
|
specify { is_expected.to include(name: 'Test') }
|
24
40
|
specify { is_expected.to include(price: 100) }
|
25
41
|
specify { is_expected.to include(status_id: 2) }
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "webmock/rspec"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe Amorail::Property do
|
5
5
|
before(:each) { mock_api }
|
6
6
|
|
7
|
-
let(:prop) {Amorail.properties}
|
7
|
+
let(:prop) { Amorail.properties }
|
8
8
|
|
9
9
|
it "should parse companies hash" do
|
10
10
|
expect(prop.company.phone.present?).to be_truthy
|
11
|
-
expect(prop.company.phone.is_a?(
|
11
|
+
expect(prop.company.phone.is_a?(described_class::PropertyItem)).to be_truthy
|
12
12
|
expect(prop.company.phone.id.present?).to be_truthy
|
13
13
|
expect(prop.company.data["phone"].data["id"]).to eq prop.company.phone.id
|
14
14
|
|
@@ -20,7 +20,7 @@ describe "spec for Amorail Properties" do
|
|
20
20
|
|
21
21
|
it "should parse contacts hash" do
|
22
22
|
expect(prop.contacts.email.present?).to be_truthy
|
23
|
-
expect(prop.contacts.im.is_a?(
|
23
|
+
expect(prop.contacts.im.is_a?(described_class::PropertyItem)).to be_truthy
|
24
24
|
expect(prop.contacts.im.id.present?).to be_truthy
|
25
25
|
expect(prop.contacts.data["im"].data["id"]).to eq prop.contacts.im.id
|
26
26
|
|
@@ -39,4 +39,4 @@ describe "spec for Amorail Properties" do
|
|
39
39
|
expect(prop.tasks.follow_up.id).to eq 1
|
40
40
|
expect(prop.tasks["CALL"].id).to eq 1
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,10 +8,12 @@ require 'webmock/rspec'
|
|
8
8
|
require 'shoulda/matchers'
|
9
9
|
require 'helpers/webmock_helpers'
|
10
10
|
|
11
|
+
ENV.clear
|
11
12
|
ENV["AMORAIL_CONF"] = File.expand_path("../fixtures/amorail_test.yml", __FILE__)
|
12
13
|
|
13
|
-
Dir[File.expand_path("../support/**/*.rb",__FILE__)].each {|f| require f}
|
14
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
|
14
15
|
|
15
16
|
RSpec.configure do |config|
|
16
17
|
config.mock_with :rspec
|
17
|
-
|
18
|
+
include AmoWebMock
|
19
|
+
end
|