dynamics_crm 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.md +10 -0
  4. data/dynamics_crm.gemspec +6 -5
  5. data/lib/dynamics_crm.rb +7 -0
  6. data/lib/dynamics_crm/client.rb +25 -14
  7. data/lib/dynamics_crm/fetch_xml/builder.rb +26 -27
  8. data/lib/dynamics_crm/metadata/attribute_metadata.rb +35 -2
  9. data/lib/dynamics_crm/metadata/attribute_query_expression.rb +25 -0
  10. data/lib/dynamics_crm/metadata/entity_metadata.rb +1 -1
  11. data/lib/dynamics_crm/metadata/entity_query_expression.rb +29 -0
  12. data/lib/dynamics_crm/metadata/filter_expression.rb +47 -0
  13. data/lib/dynamics_crm/metadata/properties_expression.rb +30 -0
  14. data/lib/dynamics_crm/metadata/retrieve_metadata_changes_response.rb +18 -0
  15. data/lib/dynamics_crm/version.rb +1 -1
  16. data/lib/dynamics_crm/xml/attributes.rb +28 -2
  17. data/lib/dynamics_crm/xml/entity_collection.rb +10 -0
  18. data/lib/dynamics_crm/xml/message_builder.rb +3 -3
  19. data/lib/dynamics_crm/xml/message_parser.rb +2 -0
  20. data/lib/dynamics_crm/xml/money.rb +16 -0
  21. data/spec/fixtures/retrieve_metadata_changes_response.xml +215 -0
  22. data/spec/lib/client_spec.rb +169 -70
  23. data/spec/lib/fetch_xml/builder_spec.rb +44 -0
  24. data/spec/lib/metadata/attribute_query_expression_spec.rb +29 -0
  25. data/spec/lib/metadata/entity_metadata_spec.rb +13 -13
  26. data/spec/lib/metadata/filter_expression_spec.rb +44 -0
  27. data/spec/lib/metadata/properties_expression_spec.rb +19 -0
  28. data/spec/lib/metadata/retrieve_all_entities_response_spec.rb +8 -8
  29. data/spec/lib/metadata/retrieve_attribute_response_spec.rb +23 -23
  30. data/spec/lib/metadata/retrieve_entity_response_spec.rb +7 -7
  31. data/spec/lib/metadata/retrieve_metadata_changes_response_spec.rb +52 -0
  32. data/spec/lib/model/opportunity_spec.rb +7 -7
  33. data/spec/lib/response/execute_result_spec.rb +4 -4
  34. data/spec/lib/response/retrieve_multiple_spec.rb +10 -10
  35. data/spec/lib/response/retrieve_result_spec.rb +26 -26
  36. data/spec/lib/xml/attributes_spec.rb +9 -9
  37. data/spec/lib/xml/column_set_spec.rb +4 -4
  38. data/spec/lib/xml/entity_reference_spec.rb +8 -8
  39. data/spec/lib/xml/entity_spec.rb +18 -18
  40. data/spec/lib/xml/fault_spec.rb +8 -8
  41. data/spec/lib/xml/money_spec.rb +41 -0
  42. data/spec/lib/xml/query_spec.rb +15 -15
  43. data/spec/spec_helper.rb +1 -0
  44. metadata +82 -32
@@ -58,6 +58,24 @@ describe DynamicsCRM::FetchXml::Builder do
58
58
  }
59
59
  end
60
60
 
61
+ it "builds a single entity with 'in' condition" do
62
+ entity = subject.entity('opportunity').add_attributes(['name', 'amount', 'ownerid'])
63
+ entity.add_condition('opportunityid', 'in', ['6055FD14-493B-E411-80BE-00155D2A4C29', '02dd7344-d04a-e411-a9d3-9cb654950300'])
64
+ expect(subject.to_xml).to eq %Q{<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
65
+ <entity name="opportunity">
66
+ <attribute name="name"/>
67
+ <attribute name="amount"/>
68
+ <attribute name="ownerid"/>
69
+ <filter type="and">
70
+ <condition attribute="opportunityid" operator="in">
71
+ <value>6055FD14-493B-E411-80BE-00155D2A4C29</value>
72
+ <value>02dd7344-d04a-e411-a9d3-9cb654950300</value>
73
+ </condition>
74
+ </filter>
75
+ </entity>
76
+ </fetch>
77
+ }
78
+ end
61
79
  end
62
80
 
63
81
  context "link_entity" do
@@ -115,6 +133,32 @@ describe DynamicsCRM::FetchXml::Builder do
115
133
  </link-entity>
116
134
  </entity>
117
135
  </fetch>
136
+ }
137
+ end
138
+
139
+ it "builds entity with link_entity and in condition" do
140
+ entity = subject.entity('opportunityproduct').add_attributes(opportunity_product_fields).order('productid')
141
+ entity.link_entity('opportunity', :alias => 'oppty').
142
+ add_condition('opportunityid', 'in', ['6055FD14-493B-E411-80BE-00155D2A4C29', '02dd7344-d04a-e411-a9d3-9cb654950300'])
143
+ expect(subject.to_xml).to eq %Q{<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
144
+ <entity name="opportunityproduct">
145
+ <attribute name="productid"/>
146
+ <attribute name="productdescription"/>
147
+ <attribute name="priceperunit"/>
148
+ <attribute name="quantity"/>
149
+ <attribute name="extendedamount"/>
150
+ <attribute name="opportunityproductid"/>
151
+ <order attribute="productid" descending="false"/>
152
+ <link-entity name="opportunity" from="opportunityid" to="opportunityid" alias="oppty" link-type="inner">
153
+ <filter type="and">
154
+ <condition attribute="opportunityid" operator="in">
155
+ <value>6055FD14-493B-E411-80BE-00155D2A4C29</value>
156
+ <value>02dd7344-d04a-e411-a9d3-9cb654950300</value>
157
+ </condition>
158
+ </filter>
159
+ </link-entity>
160
+ </entity>
161
+ </fetch>
118
162
  }
119
163
  end
120
164
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe DynamicsCRM::Metadata::AttributeQueryExpression do
4
+
5
+ describe 'initialization' do
6
+ subject {
7
+ attribute_filter = DynamicsCRM::Metadata::FilterExpression.new('And')
8
+ attribute_filter.add_condition(['IsCustomAttribute', 'Equals', true])
9
+ attribute_properties = DynamicsCRM::Metadata::PropertiesExpression.new(['LogicalName', 'AttributeType', 'DisplayName'])
10
+ DynamicsCRM::Metadata::AttributeQueryExpression.new(attribute_filter, attribute_properties)
11
+ }
12
+
13
+ context "generate attribute query expression" do
14
+ it { expect(subject.to_xml).to include("<b:AttributeQuery>") }
15
+ it { expect(subject.to_xml).to include("<b:MetadataConditionExpression>") }
16
+ it { expect(subject.to_xml).to include("<b:PropertyName>IsCustomAttribute</b:PropertyName>") }
17
+ it { expect(subject.to_xml).to include("<b:ConditionOperator>Equals</b:ConditionOperator>") }
18
+ it { expect(subject.to_xml).to match(/<b:Value i:type='e:boolean' (.*)>true<\/b:Value>/) }
19
+ it { expect(subject.to_xml).to include("<b:FilterOperator>And</b:FilterOperator>") }
20
+ it { expect(subject.to_xml).to include("<b:Properties>") }
21
+ it { expect(subject.to_xml).to include("<b:AllProperties>false</b:AllProperties>") }
22
+ it { expect(subject.to_xml).to include("<b:PropertyNames ") }
23
+ it { expect(subject.to_xml).to include("<e:string>LogicalName</e:string>") }
24
+ it { expect(subject.to_xml).to include("<e:string>AttributeType</e:string>") }
25
+ it { expect(subject.to_xml).to include("<e:string>DisplayName</e:string>") }
26
+ end
27
+
28
+ end
29
+ end
@@ -10,13 +10,13 @@ describe DynamicsCRM::Metadata::EntityMetadata do
10
10
  }
11
11
 
12
12
  context "parse attributes according to their type" do
13
- it { subject.MetadataId.should == "30b0cd7e-0081-42e1-9a48-688442277fae" }
14
- it { subject.LogicalName.should == "opportunity" }
15
- it { subject.ObjectTypeCode.should == "3" }
16
- it { subject.OwnershipType.should == "UserOwned" }
17
- it { subject.PrimaryIdAttribute.should == "opportunityid" }
18
- it { subject.PrimaryNameAttribute.should == "name" }
19
- it { subject.attributes.should == [] }
13
+ it { expect(subject.MetadataId).to eq("30b0cd7e-0081-42e1-9a48-688442277fae") }
14
+ it { expect(subject.LogicalName).to eq("opportunity") }
15
+ it { expect(subject.ObjectTypeCode).to eq("3") }
16
+ it { expect(subject.OwnershipType).to eq("UserOwned") }
17
+ it { expect(subject.PrimaryIdAttribute).to eq("opportunityid") }
18
+ it { expect(subject.PrimaryNameAttribute).to eq("name") }
19
+ it { expect(subject.attributes).to eq([]) }
20
20
  end
21
21
 
22
22
  end
@@ -29,12 +29,12 @@ describe DynamicsCRM::Metadata::EntityMetadata do
29
29
  }
30
30
 
31
31
  context "parse attributes and relationships according to their type" do
32
- it { subject.MetadataId.should == "30b0cd7e-0081-42e1-9a48-688442277fae" }
33
- it { subject.LogicalName.should == "opportunity" }
34
- it { subject.ObjectTypeCode.should == "3" }
35
- it { subject.OwnershipType.should == "UserOwned" }
36
- it { subject.PrimaryIdAttribute.should == "opportunityid" }
37
- it { subject.PrimaryNameAttribute.should == "name" }
32
+ it { expect(subject.MetadataId).to eq("30b0cd7e-0081-42e1-9a48-688442277fae") }
33
+ it { expect(subject.LogicalName).to eq("opportunity") }
34
+ it { expect(subject.ObjectTypeCode).to eq("3") }
35
+ it { expect(subject.OwnershipType).to eq("UserOwned") }
36
+ it { expect(subject.PrimaryIdAttribute).to eq("opportunityid") }
37
+ it { expect(subject.PrimaryNameAttribute).to eq("name") }
38
38
  it { expect(subject.one_to_many.size).to eq 7 }
39
39
  it { expect(subject.many_to_many.size).to eq 1 }
40
40
  it { expect(subject.many_to_one.size).to eq 8 }
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe DynamicsCRM::Metadata::FilterExpression do
4
+
5
+ describe 'initialization' do
6
+
7
+ context "generate OR filter expression XML" do
8
+ subject {
9
+ filter = DynamicsCRM::Metadata::FilterExpression.new('Or')
10
+ filter.add_condition(['SchemaName', 'Equals', 'Contact'])
11
+ filter.add_condition(['SchemaName', 'Equals', 'Annotation'])
12
+ filter.add_condition(['SchemaName', 'Equals', 'Incident'])
13
+ filter
14
+ }
15
+
16
+ it { expect(subject.to_xml).to include("<a:MetadataConditionExpression>") }
17
+ it { expect(subject.to_xml).to include("<a:PropertyName>SchemaName</a:PropertyName>") }
18
+ it { expect(subject.to_xml).to include("<a:ConditionOperator>Equals</a:ConditionOperator>") }
19
+ it { expect(subject.to_xml).to match(/<a:Value(.*)>Contact<\/a:Value>/) }
20
+ it { expect(subject.to_xml).to match(/<a:Value(.*)>Annotation<\/a:Value>/) }
21
+ it { expect(subject.to_xml).to match(/<a:Value(.*)>Incident<\/a:Value>/) }
22
+ it { expect(subject.to_xml).to include("<a:FilterOperator>Or</a:FilterOperator>") }
23
+ end
24
+
25
+ context "generate AND filter expression XML" do
26
+ subject {
27
+ filter = DynamicsCRM::Metadata::FilterExpression.new('And')
28
+ filter.add_condition(['SchemaName', 'Equals', 'Contact'])
29
+ filter.add_condition(['SchemaName', 'Equals', 'Annotation'])
30
+ filter.add_condition(['SchemaName', 'Equals', 'Incident'])
31
+ filter
32
+ }
33
+
34
+ it { expect(subject.to_xml).to include("<a:MetadataConditionExpression>") }
35
+ it { expect(subject.to_xml).to include("<a:PropertyName>SchemaName</a:PropertyName>") }
36
+ it { expect(subject.to_xml).to include("<a:ConditionOperator>Equals</a:ConditionOperator>") }
37
+ it { expect(subject.to_xml).to match(/<a:Value(.*)>Contact<\/a:Value>/) }
38
+ it { expect(subject.to_xml).to match(/<a:Value(.*)>Annotation<\/a:Value>/) }
39
+ it { expect(subject.to_xml).to match(/<a:Value(.*)>Incident<\/a:Value>/) }
40
+ it { expect(subject.to_xml).to include("<a:FilterOperator>And</a:FilterOperator>") }
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe DynamicsCRM::Metadata::PropertiesExpression do
4
+
5
+ describe 'initialization' do
6
+ subject {
7
+ DynamicsCRM::Metadata::PropertiesExpression.new(["LogicalName","AttributeType","DisplayName","Description"])
8
+ }
9
+
10
+ context "generate properties expression XML" do
11
+ it { expect(subject.to_xml({namespace: 'd'})).to include("<d:AllProperties>false</d:AllProperties>") }
12
+ it { expect(subject.to_xml).to include("<AllProperties>false</AllProperties>") }
13
+ it { expect(subject.to_xml).to include("<e:string>LogicalName</e:string>") }
14
+ it { expect(subject.to_xml).to include("<e:string>AttributeType</e:string>") }
15
+ it { expect(subject.to_xml).to include("<e:string>DisplayName</e:string>") }
16
+ it { expect(subject.to_xml).to include("<e:string>Description</e:string>") }
17
+ end
18
+ end
19
+ end
@@ -10,14 +10,14 @@ describe DynamicsCRM::Metadata::RetrieveAllEntitiesResponse do
10
10
 
11
11
  context "parse execute result" do
12
12
  let(:opportunity) { subject.entities.first }
13
- it { subject.ResponseName.should == "RetrieveAllEntities" }
14
- it { subject.entities.size.should == 3 }
15
- it { opportunity.MetadataId.should == "30b0cd7e-0081-42e1-9a48-688442277fae" }
16
- it { opportunity.LogicalName.should == "opportunity" }
17
- it { opportunity.ObjectTypeCode.should == "3" }
18
- it { opportunity.OwnershipType.should == "UserOwned" }
19
- it { opportunity.PrimaryIdAttribute.should == "opportunityid" }
20
- it { opportunity.PrimaryNameAttribute.should == "name" }
13
+ it { expect(subject.ResponseName).to eq("RetrieveAllEntities") }
14
+ it { expect(subject.entities.size).to eq(3) }
15
+ it { expect(opportunity.MetadataId).to eq("30b0cd7e-0081-42e1-9a48-688442277fae") }
16
+ it { expect(opportunity.LogicalName).to eq("opportunity") }
17
+ it { expect(opportunity.ObjectTypeCode).to eq("3") }
18
+ it { expect(opportunity.OwnershipType).to eq("UserOwned") }
19
+ it { expect(opportunity.PrimaryIdAttribute).to eq("opportunityid") }
20
+ it { expect(opportunity.PrimaryNameAttribute).to eq("name") }
21
21
 
22
22
  end
23
23
 
@@ -9,13 +9,13 @@ describe DynamicsCRM::Metadata::RetrieveAttributeResponse do
9
9
  }
10
10
 
11
11
  context "parse execute result" do
12
- it { subject.ResponseName.should == "RetrieveAttribute" }
13
- it { subject.attribute.MetadataId.should == "79194881-c699-e311-9752-6c3be5a87df0" }
14
- it { subject.attribute.AttributeType.should == "Money" }
15
- it { subject.attribute.LogicalName.should == "new_value" }
16
- it { subject.attribute.IsPrimaryId.should == "false" }
17
- it { subject.attribute.AttributeTypeName.Value.should == "MoneyType" }
18
- it { subject.attribute.DisplayName.LocalizedLabels.LocalizedLabel.Label.should == "Value" }
12
+ it { expect(subject.ResponseName).to eq("RetrieveAttribute") }
13
+ it { expect(subject.attribute.MetadataId).to eq("79194881-c699-e311-9752-6c3be5a87df0") }
14
+ it { expect(subject.attribute.AttributeType).to eq("Money") }
15
+ it { expect(subject.attribute.LogicalName).to eq("new_value") }
16
+ it { expect(subject.attribute.IsPrimaryId).to eq("false") }
17
+ it { expect(subject.attribute.AttributeTypeName.Value).to eq("MoneyType") }
18
+ it { expect(subject.attribute.DisplayName.LocalizedLabels.LocalizedLabel.Label).to eq("Value") }
19
19
  end
20
20
 
21
21
  end
@@ -27,20 +27,20 @@ describe DynamicsCRM::Metadata::RetrieveAttributeResponse do
27
27
  }
28
28
 
29
29
  context "parse execute result" do
30
- it { subject.ResponseName.should == "RetrieveAttribute" }
31
- it { subject.attribute.MetadataId.should == "ae00233e-70c0-4a1f-803f-03ff723e5440" }
32
- it { subject.attribute.AttributeType.should == "Picklist" }
33
- it { subject.attribute.LogicalName.should == "industrycode" }
34
- it { subject.attribute.EntityLogicalName.should == "account" }
35
- it { subject.attribute.AttributeTypeName.Value.should == "PicklistType" }
36
- it { subject.attribute.picklist_options.should be_a(Hash) }
30
+ it { expect(subject.ResponseName).to eq("RetrieveAttribute") }
31
+ it { expect(subject.attribute.MetadataId).to eq("ae00233e-70c0-4a1f-803f-03ff723e5440") }
32
+ it { expect(subject.attribute.AttributeType).to eq("Picklist") }
33
+ it { expect(subject.attribute.LogicalName).to eq("industrycode") }
34
+ it { expect(subject.attribute.EntityLogicalName).to eq("account") }
35
+ it { expect(subject.attribute.AttributeTypeName.Value).to eq("PicklistType") }
36
+ it { expect(subject.attribute.picklist_options).to be_a(Hash) }
37
37
  it {
38
- subject.attribute.picklist_options.should have_key(1)
39
- subject.attribute.picklist_options[1].should == "Accounting"
38
+ expect(subject.attribute.picklist_options).to have_key(1)
39
+ expect(subject.attribute.picklist_options[1]).to eq("Accounting")
40
40
  }
41
41
  it {
42
- subject.attribute.picklist_options.should have_key(33)
43
- subject.attribute.picklist_options[33].should == "Wholesale"
42
+ expect(subject.attribute.picklist_options).to have_key(33)
43
+ expect(subject.attribute.picklist_options[33]).to eq("Wholesale")
44
44
  }
45
45
  end
46
46
 
@@ -53,11 +53,11 @@ describe DynamicsCRM::Metadata::RetrieveAttributeResponse do
53
53
  }
54
54
 
55
55
  context "parse execute result" do
56
- it { subject.ResponseName.should == "RetrieveAttribute" }
57
- it { subject.attribute.MetadataId.should == "f8cd5db9-cee8-4845-8cdd-cd4f504957e7" }
58
- it { subject.attribute.AttributeType.should == "Uniqueidentifier" }
59
- it { subject.attribute.LogicalName.should == "accountid" }
60
- it { subject.attribute.EntityLogicalName.should == "account" }
56
+ it { expect(subject.ResponseName).to eq("RetrieveAttribute") }
57
+ it { expect(subject.attribute.MetadataId).to eq("f8cd5db9-cee8-4845-8cdd-cd4f504957e7") }
58
+ it { expect(subject.attribute.AttributeType).to eq("Uniqueidentifier") }
59
+ it { expect(subject.attribute.LogicalName).to eq("accountid") }
60
+ it { expect(subject.attribute.EntityLogicalName).to eq("account") }
61
61
  end
62
62
 
63
63
  end
@@ -9,13 +9,13 @@ describe DynamicsCRM::Metadata::RetrieveEntityResponse do
9
9
  }
10
10
 
11
11
  context "parse execute result" do
12
- it { subject.ResponseName.should == "RetrieveEntity" }
13
- it { subject.entity.MetadataId.should == "30b0cd7e-0081-42e1-9a48-688442277fae" }
14
- it { subject.entity.LogicalName.should == "opportunity" }
15
- it { subject.entity.ObjectTypeCode.should == "3" }
16
- it { subject.entity.OwnershipType.should == "UserOwned" }
17
- it { subject.entity.PrimaryIdAttribute.should == "opportunityid" }
18
- it { subject.entity.PrimaryNameAttribute.should == "name" }
12
+ it { expect(subject.ResponseName).to eq("RetrieveEntity") }
13
+ it { expect(subject.entity.MetadataId).to eq("30b0cd7e-0081-42e1-9a48-688442277fae") }
14
+ it { expect(subject.entity.LogicalName).to eq("opportunity") }
15
+ it { expect(subject.entity.ObjectTypeCode).to eq("3") }
16
+ it { expect(subject.entity.OwnershipType).to eq("UserOwned") }
17
+ it { expect(subject.entity.PrimaryIdAttribute).to eq("opportunityid") }
18
+ it { expect(subject.entity.PrimaryNameAttribute).to eq("name") }
19
19
 
20
20
  end
21
21
 
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe DynamicsCRM::Metadata::RetrieveMetadataChangesResponse do
4
+
5
+ describe 'retrieve_metadata_changes_response' do
6
+ subject {
7
+ file = fixture("retrieve_metadata_changes_response")
8
+ DynamicsCRM::Metadata::RetrieveMetadataChangesResponse.new(file)
9
+ }
10
+
11
+ it "parses execute result" do
12
+ expect(subject.ResponseName).to eq("RetrieveMetadataChanges")
13
+ expect(subject.entities.size).to eq(3)
14
+
15
+ entity = subject.entities[0]
16
+ expect(entity.MetadataId).to eq("e3fe4ff2-a630-49bb-a1e9-debc3a076815")
17
+ expect(entity.LogicalName).to eq("incident")
18
+ attributes = entity.attributes
19
+ expect(attributes).not_to be_nil
20
+ expect(attributes.size).to eq(2)
21
+ expect(attributes.first.logical_name).to eq('contactid')
22
+ expect(attributes.first.display_name).to eq('Contact')
23
+ expect(attributes.first.type).to eq('Lookup')
24
+ expect(attributes.first.attribute_of).to be_empty
25
+ expect(attributes.first.required_level).to eq('None')
26
+
27
+ entity = subject.entities[1]
28
+ expect(entity.MetadataId).to eq("608861bc-50a4-4c5f-a02c-21fe1943e2cf")
29
+ expect(entity.LogicalName).to eq("contact")
30
+ attributes = entity.attributes
31
+ expect(attributes).not_to be_nil
32
+ expect(attributes.size).to eq(2)
33
+ expect(attributes.first.logical_name).to eq("customertypecodename")
34
+ expect(attributes.first.attribute_of).to eq("customertypecode")
35
+ expect(attributes.first.display_name).to be_empty
36
+ expect(attributes.first.type).to eq("Virtual")
37
+ expect(attributes.first.required_level).to eq("None")
38
+
39
+ entity = subject.entities[2]
40
+ expect(entity.MetadataId).to eq("c1961a14-d4e6-470c-8d1e-23ae6b1bbb8d")
41
+ expect(entity.LogicalName).to eq("annotation")
42
+ attributes = entity.attributes
43
+ expect(attributes).not_to be_nil
44
+ expect(attributes.size).to eq(2)
45
+ expect(attributes.first.logical_name).to eq("createdonbehalfbyyominame")
46
+ expect(attributes.first.attribute_of).to eq("createdonbehalfby")
47
+ expect(attributes.first.display_name).to be_empty
48
+ expect(attributes.first.type).to eq("String")
49
+ expect(attributes.first.required_level).to eq("None")
50
+ end
51
+ end
52
+ end
@@ -10,9 +10,9 @@ describe DynamicsCRM::Model::Opportunity do
10
10
  describe '#initialize' do
11
11
 
12
12
  context "default instance" do
13
- it { subject.logical_name.should == "opportunity" }
14
- it { subject.id.should == "2dc8d7bb-149f-e311-ba8d-6c3be5a8ad64" }
15
- it { subject.client.should_not be_nil }
13
+ it { expect(subject.logical_name).to eq("opportunity") }
14
+ it { expect(subject.id).to eq("2dc8d7bb-149f-e311-ba8d-6c3be5a8ad64") }
15
+ it { expect(subject.client).not_to be_nil }
16
16
  end
17
17
 
18
18
  end
@@ -22,16 +22,16 @@ describe DynamicsCRM::Model::Opportunity do
22
22
  context "#set_as_won" do
23
23
 
24
24
  it "sets as won" do
25
- subject.client.stub(:post).and_return(fixture("win_opportunity_response"))
26
- subject.set_as_won.should == {"ResponseName"=>"WinOpportunity"}
25
+ allow(subject.client).to receive(:post).and_return(fixture("win_opportunity_response"))
26
+ expect(subject.set_as_won).to eq({"ResponseName"=>"WinOpportunity"})
27
27
  end
28
28
  end
29
29
 
30
30
  context "#set_as_lost" do
31
31
 
32
32
  it "set as lost" do
33
- subject.client.stub(:post).and_return(fixture("lose_opportunity_response"))
34
- subject.set_as_lost.should == {"ResponseName"=>"LoseOpportunity"}
33
+ allow(subject.client).to receive(:post).and_return(fixture("lose_opportunity_response"))
34
+ expect(subject.set_as_lost).to eq({"ResponseName"=>"LoseOpportunity"})
35
35
  end
36
36
  end
37
37
  end
@@ -9,10 +9,10 @@ describe DynamicsCRM::Response::ExecuteResult do
9
9
  }
10
10
 
11
11
  context "parse execute result" do
12
- it { subject.ResponseName.should == "WhoAmI" }
13
- it { subject.UserId.should == "1bfa3886-df7e-468c-8435-b5adfb0441ed" }
14
- it { subject.BusinessUnitId.should == "4e87d619-838a-e311-89a7-6c3be5a80184" }
15
- it { subject.OrganizationId.should == "0140d597-e270-494a-89e1-bd0b43774e50" }
12
+ it { expect(subject.ResponseName).to eq("WhoAmI") }
13
+ it { expect(subject.UserId).to eq("1bfa3886-df7e-468c-8435-b5adfb0441ed") }
14
+ it { expect(subject.BusinessUnitId).to eq("4e87d619-838a-e311-89a7-6c3be5a80184") }
15
+ it { expect(subject.OrganizationId).to eq("0140d597-e270-494a-89e1-bd0b43774e50") }
16
16
  end
17
17
 
18
18
  end
@@ -10,21 +10,21 @@ describe DynamicsCRM::Response::RetrieveMultipleResult do
10
10
 
11
11
  context "parse attributes according to their type" do
12
12
 
13
- it { subject.EntityName.should == "account" }
14
- it { subject.MinActiveRowVersion.should == -1}
15
- it { subject.MoreRecords.should == false }
16
- it { subject.PagingCookie.should include("cookie page=") }
17
- it { subject.TotalRecordCount.should == -1 }
18
- it { subject.TotalRecordCountLimitExceeded.should == false }
19
- it { subject.entities.size.should == 3 }
20
-
21
- it { subject.entities.first.to_hash.should == {
13
+ it { expect(subject.EntityName).to eq("account") }
14
+ it { expect(subject.MinActiveRowVersion).to eq(-1)}
15
+ it { expect(subject.MoreRecords).to eq(false) }
16
+ it { expect(subject.PagingCookie).to include("cookie page=") }
17
+ it { expect(subject.TotalRecordCount).to eq(-1) }
18
+ it { expect(subject.TotalRecordCountLimitExceeded).to eq(false) }
19
+ it { expect(subject.entities.size).to eq(3) }
20
+
21
+ it { expect(subject.entities.first.to_hash).to eq({
22
22
  :attributes => {"accountid"=>"7bf2e032-ad92-e311-9752-6c3be5a87df0"},
23
23
  :entity_state => nil,
24
24
  :formatted_values => nil,
25
25
  :id => "7bf2e032-ad92-e311-9752-6c3be5a87df0",
26
26
  :logical_name => "account",
27
- :related_entities => nil}
27
+ :related_entities => nil})
28
28
  }
29
29
 
30
30
  end