spark_api 1.4.28 → 1.5.0
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 +5 -13
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/spark_api/authentication/api_auth.rb +1 -1
- data/lib/spark_api/authentication/oauth2.rb +1 -1
- data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb +1 -1
- data/lib/spark_api/client.rb +2 -2
- data/lib/spark_api/models.rb +1 -0
- data/lib/spark_api/models/account.rb +7 -1
- data/lib/spark_api/models/account_report.rb +0 -5
- data/lib/spark_api/models/floplan.rb +24 -0
- data/lib/spark_api/models/listing.rb +11 -1
- data/lib/spark_api/models/subresource.rb +2 -2
- data/lib/spark_api/request.rb +2 -2
- data/script/reso_middleware_example.rb +70 -0
- data/spec/fixtures/listings/floplans_index.json +15 -0
- data/spec/spec_helper.rb +9 -4
- data/spec/unit/spark_api/authentication/api_auth_spec.rb +21 -22
- data/spec/unit/spark_api/authentication/base_auth_spec.rb +3 -3
- data/spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb +1 -1
- data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb +1 -1
- data/spec/unit/spark_api/authentication/oauth2_impl/single_session_provider_spec.rb +2 -2
- data/spec/unit/spark_api/authentication/oauth2_spec.rb +40 -40
- data/spec/unit/spark_api/authentication_spec.rb +2 -2
- data/spec/unit/spark_api/configuration/yaml_spec.rb +44 -44
- data/spec/unit/spark_api/configuration_spec.rb +56 -57
- data/spec/unit/spark_api/faraday_middleware_spec.rb +12 -12
- data/spec/unit/spark_api/models/account_report_spec.rb +2 -22
- data/spec/unit/spark_api/models/account_spec.rb +24 -21
- data/spec/unit/spark_api/models/activity_spec.rb +5 -5
- data/spec/unit/spark_api/models/base_spec.rb +32 -32
- data/spec/unit/spark_api/models/concerns/destroyable_spec.rb +2 -2
- data/spec/unit/spark_api/models/concerns/savable_spec.rb +19 -19
- data/spec/unit/spark_api/models/connect_prefs_spec.rb +1 -1
- data/spec/unit/spark_api/models/constraint_spec.rb +1 -1
- data/spec/unit/spark_api/models/contact_spec.rb +50 -50
- data/spec/unit/spark_api/models/dirty_spec.rb +12 -12
- data/spec/unit/spark_api/models/document_spec.rb +3 -3
- data/spec/unit/spark_api/models/fields_spec.rb +17 -17
- data/spec/unit/spark_api/models/finders_spec.rb +7 -7
- data/spec/unit/spark_api/models/floplan_spec.rb +24 -0
- data/spec/unit/spark_api/models/listing_cart_spec.rb +46 -46
- data/spec/unit/spark_api/models/listing_meta_translations_spec.rb +6 -6
- data/spec/unit/spark_api/models/listing_spec.rb +91 -91
- data/spec/unit/spark_api/models/message_spec.rb +10 -10
- data/spec/unit/spark_api/models/note_spec.rb +10 -10
- data/spec/unit/spark_api/models/notification_spec.rb +6 -6
- data/spec/unit/spark_api/models/open_house_spec.rb +4 -4
- data/spec/unit/spark_api/models/photo_spec.rb +8 -8
- data/spec/unit/spark_api/models/portal_spec.rb +4 -4
- data/spec/unit/spark_api/models/property_types_spec.rb +5 -5
- data/spec/unit/spark_api/models/rental_calendar_spec.rb +13 -11
- data/spec/unit/spark_api/models/rule_spec.rb +2 -2
- data/spec/unit/spark_api/models/saved_search_spec.rb +33 -33
- data/spec/unit/spark_api/models/search_template/quick_search_spec.rb +5 -5
- data/spec/unit/spark_api/models/shared_listing_spec.rb +12 -12
- data/spec/unit/spark_api/models/sort_spec.rb +3 -3
- data/spec/unit/spark_api/models/standard_fields_spec.rb +12 -12
- data/spec/unit/spark_api/models/subresource_spec.rb +33 -15
- data/spec/unit/spark_api/models/system_info_spec.rb +7 -7
- data/spec/unit/spark_api/models/tour_of_home_spec.rb +3 -3
- data/spec/unit/spark_api/models/video_spec.rb +9 -9
- data/spec/unit/spark_api/models/virtual_tour_spec.rb +7 -7
- data/spec/unit/spark_api/models/vow_account_spec.rb +8 -8
- data/spec/unit/spark_api/multi_client_spec.rb +14 -14
- data/spec/unit/spark_api/options_hash_spec.rb +4 -4
- data/spec/unit/spark_api/paginate_spec.rb +71 -71
- data/spec/unit/spark_api/primary_array_spec.rb +5 -5
- data/spec/unit/spark_api/request_spec.rb +65 -59
- data/spec/unit/spark_api_spec.rb +6 -6
- metadata +215 -280
@@ -13,7 +13,7 @@ describe Constraint do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should print to string" do
|
16
|
-
subject.to_s.
|
16
|
+
expect(subject.to_s).to eq("MaxValue: Field(ListPrice,1.0) Value(1000000.0,1000001.0)")
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -6,8 +6,8 @@ describe Contact do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should include the finders module" do
|
9
|
-
Contact.
|
10
|
-
Contact.
|
9
|
+
expect(Contact).to respond_to(:find)
|
10
|
+
expect(Contact).to respond_to(:my)
|
11
11
|
end
|
12
12
|
|
13
13
|
context "/contacts", :support do
|
@@ -15,9 +15,9 @@ describe Contact do
|
|
15
15
|
on_get_it "should get all my contacts" do
|
16
16
|
stub_api_get("/contacts", 'contacts/contacts.json')
|
17
17
|
contacts = Contact.get
|
18
|
-
contacts.
|
19
|
-
contacts.length.
|
20
|
-
contacts.first.Id.
|
18
|
+
expect(contacts).to be_an(Array)
|
19
|
+
expect(contacts.length).to eq(3)
|
20
|
+
expect(contacts.first.Id).to eq("20101230223226074201000000")
|
21
21
|
end
|
22
22
|
|
23
23
|
on_post_it "should save a new contact" do
|
@@ -25,8 +25,8 @@ describe Contact do
|
|
25
25
|
c=Contact.new
|
26
26
|
c.DisplayName = "Contact Four"
|
27
27
|
c.PrimaryEmail = "contact4@fbsdata.com"
|
28
|
-
c.save.
|
29
|
-
c.Id.
|
28
|
+
expect(c.save).to be(true)
|
29
|
+
expect(c.Id).to eq('20101230223226074204000000')
|
30
30
|
end
|
31
31
|
|
32
32
|
on_post_it "should save a new contact and notify" do
|
@@ -35,9 +35,9 @@ describe Contact do
|
|
35
35
|
c.notify = true
|
36
36
|
c.attributes["DisplayName"] = "Contact Four"
|
37
37
|
c.attributes["PrimaryEmail"] = "contact4@fbsdata.com"
|
38
|
-
c.save.
|
39
|
-
c.Id.
|
40
|
-
c.ResourceUri.
|
38
|
+
expect(c.save).to be(true)
|
39
|
+
expect(c.Id).to eq('20101230223226074204000000')
|
40
|
+
expect(c.ResourceUri).to eq('/v1/contacts/20101230223226074204000000')
|
41
41
|
end
|
42
42
|
|
43
43
|
on_post_it "should fail saving" do
|
@@ -46,8 +46,8 @@ describe Contact do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
c=Contact.new
|
49
|
-
c.save.
|
50
|
-
expect{ c.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
49
|
+
expect(c.save).to be(false)
|
50
|
+
expect{ c.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(400) }
|
51
51
|
end
|
52
52
|
|
53
53
|
on_post_it "should fail saving and set @errors" do
|
@@ -56,10 +56,10 @@ describe Contact do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
c=Contact.new
|
59
|
-
c.errors.length.
|
60
|
-
c.save.
|
61
|
-
c.errors.length.
|
62
|
-
c.errors.first[:code].
|
59
|
+
expect(c.errors.length).to eq(0)
|
60
|
+
expect(c.save).to be false
|
61
|
+
expect(c.errors.length).to eq(1)
|
62
|
+
expect(c.errors.first[:code]).to eq(1055)
|
63
63
|
end
|
64
64
|
|
65
65
|
context "on an epic fail" do
|
@@ -69,8 +69,8 @@ describe Contact do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
c=Contact.new()
|
72
|
-
expect{ c.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
73
|
-
expect{ c.save }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
72
|
+
expect{ c.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(500) }
|
73
|
+
expect{ c.save }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(500) }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -78,9 +78,9 @@ describe Contact do
|
|
78
78
|
on_get_it "should get all my Tags" do
|
79
79
|
stub_api_get("/contacts/tags", 'contacts/tags.json')
|
80
80
|
tags = Contact.tags
|
81
|
-
tags.
|
82
|
-
tags.length.
|
83
|
-
tags.first["Tag"].
|
81
|
+
expect(tags).to be_an(Array)
|
82
|
+
expect(tags.length).to eq(4)
|
83
|
+
expect(tags.first["Tag"]).to eq("Current Buyers")
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -88,30 +88,30 @@ describe Contact do
|
|
88
88
|
on_get_it "should get all contacts with Tag <tag_name>" do
|
89
89
|
stub_api_get("/contacts/tags/IDX%20Lead", 'contacts/contacts.json')
|
90
90
|
contacts = Contact.by_tag("IDX Lead")
|
91
|
-
contacts.
|
92
|
-
contacts.length.
|
93
|
-
contacts.first.Id.
|
94
|
-
contacts.first.Tags[0].
|
91
|
+
expect(contacts).to be_an(Array)
|
92
|
+
expect(contacts.length).to eq(3)
|
93
|
+
expect(contacts.first.Id).to eq("20101230223226074201000000")
|
94
|
+
expect(contacts.first.Tags[0]).to eq("IDX Lead")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
98
|
context "/export", :support do
|
99
99
|
on_get_it "should get all contacts belonging to the current user" do
|
100
100
|
stub_api_get("/contacts/export", 'contacts/contacts.json')
|
101
|
-
Contact.
|
101
|
+
expect(Contact).to respond_to(:export)
|
102
102
|
contacts = Contact.export
|
103
|
-
contacts.
|
104
|
-
contacts.length.
|
103
|
+
expect(contacts).to be_an(Array)
|
104
|
+
expect(contacts.length).to eq(3)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
context "/export/all", :support do
|
109
109
|
on_get_it "should get all contacts belonging to the current user" do
|
110
110
|
stub_api_get("/contacts/export/all", 'contacts/contacts.json')
|
111
|
-
Contact.
|
111
|
+
expect(Contact).to respond_to(:export_all)
|
112
112
|
contacts = Contact.export_all
|
113
|
-
contacts.
|
114
|
-
contacts.length.
|
113
|
+
expect(contacts).to be_an(Array)
|
114
|
+
expect(contacts.length).to eq(3)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -131,8 +131,8 @@ describe Contact do
|
|
131
131
|
on_get_it "should get all the saved searches belonging to the customer" do
|
132
132
|
stub_api_get("/contacts/#{contact.Id}/savedsearches", 'saved_searches/get.json')
|
133
133
|
saved_searches = contact.saved_searches
|
134
|
-
saved_searches.
|
135
|
-
saved_searches.length.
|
134
|
+
expect(saved_searches).to be_an(Array)
|
135
|
+
expect(saved_searches.length).to eq(2)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should pass any arguments as parameters" do
|
@@ -152,8 +152,8 @@ describe Contact do
|
|
152
152
|
on_get_it "should get all the provided searches belonging to the customer" do
|
153
153
|
stub_api_get("/contacts/#{contact.Id}/provided/savedsearches", 'saved_searches/get.json')
|
154
154
|
saved_searches = contact.provided_searches
|
155
|
-
saved_searches.
|
156
|
-
saved_searches.length.
|
155
|
+
expect(saved_searches).to be_an(Array)
|
156
|
+
expect(saved_searches.length).to eq(2)
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should pass any arguments as parameters" do
|
@@ -173,8 +173,8 @@ describe Contact do
|
|
173
173
|
on_get_it "should get all the listing carts belonging to the customer" do
|
174
174
|
stub_api_get("/contacts/#{contact.Id}/listingcarts", 'listing_carts/listing_cart.json')
|
175
175
|
listing_carts = contact.listing_carts
|
176
|
-
listing_carts.
|
177
|
-
listing_carts.length.
|
176
|
+
expect(listing_carts).to be_an(Array)
|
177
|
+
expect(listing_carts.length).to eq(2)
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should pass any arguments as parameters" do
|
@@ -189,7 +189,7 @@ describe Contact do
|
|
189
189
|
contact = Contact.my
|
190
190
|
stub_api_get("/contacts/#{contact.Id}/portal", 'contacts/vow_accounts/get.json')
|
191
191
|
vow_account = contact.vow_account
|
192
|
-
vow_account.persisted
|
192
|
+
expect(vow_account.persisted?).to be true
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
@@ -198,17 +198,17 @@ describe Contact do
|
|
198
198
|
it "should get all of a contact's comments" do
|
199
199
|
s = stub_api_get("/contacts/#{contact_id}/comments", "comments/get.json")
|
200
200
|
comments = Contact.new(:Id => contact_id).comments
|
201
|
-
comments.size.
|
202
|
-
s.
|
201
|
+
expect(comments.size).to eq(2)
|
202
|
+
expect(s).to have_been_requested
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should create a new contact comment" do
|
206
206
|
s = stub_api_post("/contacts/#{contact_id}/comments", "comments/new.json", "comments/post.json")
|
207
207
|
comment = Comment.new(:Comment => "This is a comment.")
|
208
208
|
comment.parent = Contact.new(:Id => contact_id)
|
209
|
-
comment.save.
|
210
|
-
comment.Id.
|
211
|
-
s.
|
209
|
+
expect(comment.save).to be(true)
|
210
|
+
expect(comment.Id).to eq("20121114100201798092000005")
|
211
|
+
expect(s).to have_been_requested
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should create a new contact comment using helper method" do
|
@@ -216,8 +216,8 @@ describe Contact do
|
|
216
216
|
s = stub_api_post("/contacts/#{contact_id}/comments", "comments/new.json", "comments/post.json")
|
217
217
|
contact = Contact.my
|
218
218
|
comment = contact.comment "This is a comment."
|
219
|
-
comment.
|
220
|
-
s.
|
219
|
+
expect(comment).to be_a(Comment)
|
220
|
+
expect(s).to have_been_requested
|
221
221
|
end
|
222
222
|
|
223
223
|
end
|
@@ -230,8 +230,8 @@ describe Contact do
|
|
230
230
|
stub_api_get("/contacts/#{contact_id}/comments", "comments/get.json")
|
231
231
|
s = stub_api_delete("/activities/20121128132106172132000004/comments/#{id}", "success.json")
|
232
232
|
comment = Contact.new(:Id => contact_id).comments.first
|
233
|
-
comment.destroy.
|
234
|
-
s.
|
233
|
+
expect(comment.destroy).to eq(true)
|
234
|
+
expect(s).to have_been_requested
|
235
235
|
end
|
236
236
|
|
237
237
|
end
|
@@ -242,9 +242,9 @@ describe Contact do
|
|
242
242
|
on_get_it "should get a single contact when using #my" do
|
243
243
|
stub_api_get("/my/contact", 'contacts/my.json')
|
244
244
|
contact = Contact.my
|
245
|
-
contact.
|
246
|
-
contact.Id.
|
247
|
-
contact.DisplayName.
|
245
|
+
expect(contact).to be_a(Contact)
|
246
|
+
expect(contact.Id).to eq('20090928182824338901000000')
|
247
|
+
expect(contact.DisplayName).to eq('BH FOO')
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
@@ -15,15 +15,15 @@ describe Dirty do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "lets you know if you've changed any attributes" do
|
18
|
-
@model.changed
|
18
|
+
expect(@model.changed?).to be true
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return an array of the attributes that have been changed" do
|
22
|
-
@model.changed.
|
22
|
+
expect(@model.changed).to eq(["Name"])
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return a hash diff of current changes on a model" do
|
26
|
-
@model.changes.
|
26
|
+
expect(@model.changes).to eq({
|
27
27
|
"Name" => ["some old name", "a new name"]
|
28
28
|
})
|
29
29
|
end
|
@@ -31,34 +31,34 @@ describe Dirty do
|
|
31
31
|
it "should return previously changed attributes after save" do
|
32
32
|
stub_api_post('/test/example', { :MyExampleModels => [ @model.attributes ] }, 'base.json')
|
33
33
|
@model.save
|
34
|
-
@model.previous_changes.
|
34
|
+
expect(@model.previous_changes).to eq({
|
35
35
|
})
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return changed attributes with old values" do
|
39
|
-
@model.changed_attributes.
|
39
|
+
expect(@model.changed_attributes).to eq({
|
40
40
|
"Name" => "some old name"
|
41
41
|
})
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should return changed attributes with new values" do
|
45
|
-
@model.dirty_attributes.
|
45
|
+
expect(@model.dirty_attributes).to eq({
|
46
46
|
"Name" => "a new name"
|
47
47
|
})
|
48
48
|
end
|
49
49
|
|
50
50
|
it "does not mark attributes dirty when initialized" do
|
51
51
|
@model = MyExampleModel.new(:Name => "some sort of name")
|
52
|
-
@model.attributes.size.
|
53
|
-
@model.changed_attributes.
|
54
|
-
@model.dirty_attributes.
|
52
|
+
expect(@model.attributes.size).to eq(1)
|
53
|
+
expect(@model.changed_attributes).to eq({})
|
54
|
+
expect(@model.dirty_attributes).to eq({})
|
55
55
|
end
|
56
56
|
|
57
57
|
it "marks attributes dirty that are loaded later" do
|
58
58
|
@model.load(:Name => "some sort of name")
|
59
|
-
@model.attributes.size.
|
60
|
-
@model.changed_attributes.
|
61
|
-
@model.dirty_attributes.
|
59
|
+
expect(@model.attributes.size).to eq(1)
|
60
|
+
expect(@model.changed_attributes).to eq({"Name"=>"some old name"})
|
61
|
+
expect(@model.dirty_attributes).to eq({"Name"=>"some sort of name"})
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -11,7 +11,7 @@ describe Document do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should respond to a few methods" do
|
14
|
-
Document.
|
14
|
+
expect(Document).to respond_to(:find_by_listing_key)
|
15
15
|
end
|
16
16
|
|
17
17
|
context "/listings/<listing_id>/documents" do
|
@@ -20,8 +20,8 @@ describe Document do
|
|
20
20
|
stub_api_get('/listings/1234/documents','listings/document_index.json')
|
21
21
|
|
22
22
|
v = Document.find_by_listing_key('1234')
|
23
|
-
v.
|
24
|
-
v.length.
|
23
|
+
expect(v).to be_an(Array)
|
24
|
+
expect(v.length).to eq(2)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -7,7 +7,7 @@ describe Fields do
|
|
7
7
|
|
8
8
|
context "/fields/order", :support do
|
9
9
|
on_get_it "should find field orders for all property types" do
|
10
|
-
Fields.
|
10
|
+
expect(Fields).to respond_to(:order)
|
11
11
|
|
12
12
|
# stub request
|
13
13
|
stub_api_get('/fields/order','fields/order.json')
|
@@ -16,20 +16,20 @@ describe Fields do
|
|
16
16
|
resources = subject.class.order
|
17
17
|
|
18
18
|
# a standard array of results
|
19
|
-
resources.
|
20
|
-
resources.length.
|
19
|
+
expect(resources).to be_an(Array)
|
20
|
+
expect(resources.length).to eq(1)
|
21
21
|
|
22
22
|
# make sure multiple property types are present
|
23
|
-
resources.first.
|
24
|
-
resources.first.
|
23
|
+
expect(resources.first).to have_key("A")
|
24
|
+
expect(resources.first).to have_key("B")
|
25
25
|
|
26
|
-
resources.first["A"].
|
26
|
+
expect(resources.first["A"]).to be_an(Array)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
context "/fields/order/<property_type>", :support do
|
31
31
|
on_get_it "should find field order for a single property type" do
|
32
|
-
Fields.
|
32
|
+
expect(Fields).to respond_to(:order)
|
33
33
|
|
34
34
|
# stub request
|
35
35
|
stub_api_get('/fields/order/A','fields/order_a.json')
|
@@ -38,15 +38,15 @@ describe Fields do
|
|
38
38
|
resources = subject.class.order("A")
|
39
39
|
|
40
40
|
# a standard array of results
|
41
|
-
resources.
|
42
|
-
resources.length.
|
41
|
+
expect(resources).to be_an(Array)
|
42
|
+
expect(resources.length).to eq(2)
|
43
43
|
|
44
44
|
# validate a single entity
|
45
45
|
group = resources.first[resources.first.keys.first]
|
46
|
-
group.
|
47
|
-
group.length.
|
46
|
+
expect(group).to be_an(Array)
|
47
|
+
expect(group.length).to eq(2)
|
48
48
|
group.each do |field|
|
49
|
-
field.
|
49
|
+
expect(field).to have_key("Field")
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -54,7 +54,7 @@ describe Fields do
|
|
54
54
|
|
55
55
|
context "/fields/order/settings", :support do
|
56
56
|
on_get_it "returns the field order settings" do
|
57
|
-
Fields.
|
57
|
+
expect(Fields).to respond_to(:settings)
|
58
58
|
|
59
59
|
# stub request
|
60
60
|
stub_api_get('/fields/order/settings','fields/settings.json')
|
@@ -63,12 +63,12 @@ describe Fields do
|
|
63
63
|
settings = subject.class.settings
|
64
64
|
|
65
65
|
# a standard array of results
|
66
|
-
settings.
|
67
|
-
settings.length.
|
66
|
+
expect(settings).to be_an(Array)
|
67
|
+
expect(settings.length).to eq(1)
|
68
68
|
|
69
69
|
# make sure ShowingInstructions is present
|
70
|
-
settings.first.
|
71
|
-
settings.first["ShowingInstructions"].
|
70
|
+
expect(settings.first).to have_key("ShowingInstructions")
|
71
|
+
expect(settings.first["ShowingInstructions"]).to be_an(Array)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -14,13 +14,13 @@ describe Finders, "Finders model" do
|
|
14
14
|
it "should get first result" do
|
15
15
|
stub_api_get("/my_resource", 'finders.json')
|
16
16
|
resource = MyResource.first
|
17
|
-
resource.Id.
|
17
|
+
expect(resource.Id).to eq(1)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should get last result" do
|
21
21
|
stub_api_get("/my_resource", 'finders.json')
|
22
22
|
resource = MyResource.last
|
23
|
-
resource.Id.
|
23
|
+
expect(resource.Id).to eq(2)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should find one result" do
|
@@ -29,23 +29,23 @@ describe Finders, "Finders model" do
|
|
29
29
|
:_filter => "Something Eq 'dude'"
|
30
30
|
})
|
31
31
|
resource = MyResource.find_one(:_filter => "Something Eq 'dude'")
|
32
|
-
resource.Id.
|
32
|
+
expect(resource.Id).to eq(1)
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "find" do
|
36
36
|
|
37
37
|
it "should throw an error if no argument is passed" do
|
38
38
|
stub_api_get("/my_resource/", 'finders.json')
|
39
|
-
|
39
|
+
expect {
|
40
40
|
MyResource.find()
|
41
|
-
}.
|
41
|
+
}.to raise_error(ArgumentError)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should throw an error when the first argument is nil" do
|
45
45
|
stub_api_get("/my_resource/", 'finders.json', {:_limit => 1})
|
46
|
-
|
46
|
+
expect {
|
47
47
|
MyResource.find(nil, {:_limit => 1})
|
48
|
-
}.
|
48
|
+
}.to raise_error(ArgumentError)
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|