spark_api 1.4.34 → 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 +4 -4
- 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/request.rb +1 -1
- 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_spec.rb +20 -20
- 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 +4 -4
- 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 +18 -18
- 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 +60 -60
- data/spec/unit/spark_api_spec.rb +6 -6
- metadata +162 -233
@@ -6,9 +6,9 @@ describe SparkApi::OptionsHash do
|
|
6
6
|
"parameter_two" => 2,
|
7
7
|
3 => 3}
|
8
8
|
o_h = SparkApi::OptionsHash.new(h)
|
9
|
-
o_h.keys.size.
|
10
|
-
o_h["parameter_one"].
|
11
|
-
o_h["parameter_two"].
|
12
|
-
o_h[3].
|
9
|
+
expect(o_h.keys.size).to eq(3)
|
10
|
+
expect(o_h["parameter_one"]).to eq(1)
|
11
|
+
expect(o_h["parameter_two"]).to eq(2)
|
12
|
+
expect(o_h[3]).to eq(3)
|
13
13
|
end
|
14
14
|
end
|
@@ -37,54 +37,54 @@ describe SparkApi::PaginateResponse do
|
|
37
37
|
json = "{#{paginate_json}}"
|
38
38
|
hash = JSON.parse(json)
|
39
39
|
results = subject.paginate_response([1,2,3,4,5,6,7,8,9,10], hash["Pagination"])
|
40
|
-
results.offset.
|
41
|
-
results.next_page.
|
42
|
-
results.previous_page.
|
43
|
-
results.current_page.
|
44
|
-
results.per_page.
|
45
|
-
results.total_pages.
|
46
|
-
results.total_entries.
|
47
|
-
results[0].
|
40
|
+
expect(results.offset).to eq(0)
|
41
|
+
expect(results.next_page).to eq(2)
|
42
|
+
expect(results.previous_page).to eq(nil)
|
43
|
+
expect(results.current_page).to eq(1)
|
44
|
+
expect(results.per_page).to eq(10)
|
45
|
+
expect(results.total_pages).to eq(4)
|
46
|
+
expect(results.total_entries).to eq(38)
|
47
|
+
expect(results[0]).to eq(1)
|
48
48
|
end
|
49
49
|
it "should give me the second page" do
|
50
50
|
json = "{#{paginate_json(2)}}"
|
51
51
|
hash = JSON.parse(json)
|
52
52
|
results = subject.paginate_response([11,12,13,14,15,16,17,18,19,20], hash["Pagination"])
|
53
|
-
results.offset.
|
54
|
-
results.next_page.
|
55
|
-
results.previous_page.
|
56
|
-
results.current_page.
|
57
|
-
results.per_page.
|
58
|
-
results.total_pages.
|
59
|
-
results.total_entries.
|
60
|
-
results[0].
|
53
|
+
expect(results.offset).to eq(10)
|
54
|
+
expect(results.next_page).to eq(3)
|
55
|
+
expect(results.previous_page).to eq(1)
|
56
|
+
expect(results.current_page).to eq(2)
|
57
|
+
expect(results.per_page).to eq(10)
|
58
|
+
expect(results.total_pages).to eq(4)
|
59
|
+
expect(results.total_entries).to eq(38)
|
60
|
+
expect(results[0]).to eq(11)
|
61
61
|
end
|
62
62
|
it "should give me the third page" do
|
63
63
|
json = "{#{paginate_json(3)}}"
|
64
64
|
hash = JSON.parse(json)
|
65
65
|
results = subject.paginate_response([21,22,23,24,25,26,27,28,29,30], hash["Pagination"])
|
66
|
-
results.offset.
|
67
|
-
results.next_page.
|
68
|
-
results.previous_page.
|
69
|
-
results.current_page.
|
70
|
-
results.per_page.
|
71
|
-
results.total_pages.
|
72
|
-
results.total_entries.
|
73
|
-
results[0].
|
66
|
+
expect(results.offset).to eq(20)
|
67
|
+
expect(results.next_page).to eq(4)
|
68
|
+
expect(results.previous_page).to eq(2)
|
69
|
+
expect(results.current_page).to eq(3)
|
70
|
+
expect(results.per_page).to eq(10)
|
71
|
+
expect(results.total_pages).to eq(4)
|
72
|
+
expect(results.total_entries).to eq(38)
|
73
|
+
expect(results[0]).to eq(21)
|
74
74
|
end
|
75
75
|
it "should give me the last page" do
|
76
76
|
json = "{#{paginate_json(4)}}"
|
77
77
|
hash = JSON.parse(json)
|
78
78
|
results = subject.paginate_response([31,32,33,34,35,36,37,38], hash["Pagination"])
|
79
|
-
results.offset.
|
80
|
-
results.next_page.
|
81
|
-
results.previous_page.
|
82
|
-
results.current_page.
|
83
|
-
results.per_page.
|
84
|
-
results.total_pages.
|
85
|
-
results.total_entries.
|
86
|
-
results[0].
|
87
|
-
results[-1].
|
79
|
+
expect(results.offset).to eq(30)
|
80
|
+
expect(results.next_page).to eq(nil)
|
81
|
+
expect(results.previous_page).to eq(3)
|
82
|
+
expect(results.current_page).to eq(4)
|
83
|
+
expect(results.per_page).to eq(10)
|
84
|
+
expect(results.total_pages).to eq(4)
|
85
|
+
expect(results.total_entries).to eq(38)
|
86
|
+
expect(results[0]).to eq(31)
|
87
|
+
expect(results[-1]).to eq(38)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -93,27 +93,27 @@ describe SparkApi::Paginate do
|
|
93
93
|
describe "paginate" do
|
94
94
|
it "should give me a will paginate collection" do
|
95
95
|
results = PaginateModelTester.paginate(:page => 1)
|
96
|
-
results.
|
97
|
-
results.offset.
|
98
|
-
results.next_page.
|
99
|
-
results.previous_page.
|
100
|
-
results.current_page.
|
101
|
-
results.per_page.
|
102
|
-
results.total_pages.
|
103
|
-
results.total_entries.
|
96
|
+
expect(results).to be_a(WillPaginate::Collection)
|
97
|
+
expect(results.offset).to eq(0)
|
98
|
+
expect(results.next_page).to eq(2)
|
99
|
+
expect(results.previous_page).to eq(nil)
|
100
|
+
expect(results.current_page).to eq(1)
|
101
|
+
expect(results.per_page).to eq(10)
|
102
|
+
expect(results.total_pages).to eq(4)
|
103
|
+
expect(results.total_entries).to eq(38)
|
104
104
|
|
105
|
-
results[0].
|
106
|
-
results[0].val.
|
105
|
+
expect(results[0]).to be_a(PaginateModelTester)
|
106
|
+
expect(results[0].val).to eq(1)
|
107
107
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should give me pagination options" do
|
111
111
|
PaginateModelTester.paginate(:page => 1)
|
112
112
|
opts = PaginateModelTester.options
|
113
|
-
opts["_pagination"].
|
114
|
-
opts["_limit"].
|
115
|
-
opts["_page"].
|
116
|
-
opts.has_key?(:page).
|
113
|
+
expect(opts["_pagination"]).to eq(1)
|
114
|
+
expect(opts["_limit"]).to eq(25)
|
115
|
+
expect(opts["_page"]).to eq(1)
|
116
|
+
expect(opts.has_key?(:page)).to eq(false)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -121,7 +121,7 @@ describe SparkApi::Paginate do
|
|
121
121
|
it "should set the default model max results per page" do
|
122
122
|
results = PaginateModelTester50.paginate(:page => 1)
|
123
123
|
opts = PaginateModelTester50.options
|
124
|
-
opts["_limit"].
|
124
|
+
expect(opts["_limit"]).to eq(50)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -151,18 +151,18 @@ describe SparkApi::Paginate do
|
|
151
151
|
}).
|
152
152
|
to_return(:body => json)
|
153
153
|
results = subject.paginate(:page=>1, :per_page=>10)
|
154
|
-
results.
|
155
|
-
results.offset.
|
156
|
-
results.next_page.
|
157
|
-
results.previous_page.
|
158
|
-
results.current_page.
|
159
|
-
results.per_page.
|
160
|
-
results.total_pages.
|
161
|
-
results.total_entries.
|
162
|
-
results.length.
|
154
|
+
expect(results).to be_a(WillPaginate::Collection)
|
155
|
+
expect(results.offset).to eq(0)
|
156
|
+
expect(results.next_page).to eq(2)
|
157
|
+
expect(results.previous_page).to eq(nil)
|
158
|
+
expect(results.current_page).to eq(1)
|
159
|
+
expect(results.per_page).to eq(10)
|
160
|
+
expect(results.total_pages).to eq(4)
|
161
|
+
expect(results.total_entries).to eq(38)
|
162
|
+
expect(results.length).to eq(10)
|
163
163
|
|
164
|
-
results[0].
|
165
|
-
results[0].ListPrice.
|
164
|
+
expect(results[0]).to be_a(subject)
|
165
|
+
expect(results[0].ListPrice).to eq(50000.0)
|
166
166
|
|
167
167
|
end
|
168
168
|
it "gives me page two of listings" do
|
@@ -184,9 +184,9 @@ describe SparkApi::Paginate do
|
|
184
184
|
}).
|
185
185
|
to_return(:body => json)
|
186
186
|
results = subject.paginate(:page=>2, :per_page=>10)
|
187
|
-
results.next_page.
|
188
|
-
results.previous_page.
|
189
|
-
results.current_page.
|
187
|
+
expect(results.next_page).to eq(3)
|
188
|
+
expect(results.previous_page).to eq(1)
|
189
|
+
expect(results.current_page).to eq(2)
|
190
190
|
end
|
191
191
|
it "gives me page four of listings" do
|
192
192
|
json = <<-JSON
|
@@ -207,16 +207,16 @@ describe SparkApi::Paginate do
|
|
207
207
|
}).
|
208
208
|
to_return(:body => json)
|
209
209
|
results = subject.paginate(:page=>4, :per_page=>10)
|
210
|
-
results.next_page.
|
211
|
-
results.previous_page.
|
212
|
-
results.current_page.
|
213
|
-
results.per_page.
|
214
|
-
results.total_pages.
|
215
|
-
results.total_entries.
|
210
|
+
expect(results.next_page).to eq(nil)
|
211
|
+
expect(results.previous_page).to eq(3)
|
212
|
+
expect(results.current_page).to eq(4)
|
213
|
+
expect(results.per_page).to eq(10)
|
214
|
+
expect(results.total_pages).to eq(4)
|
215
|
+
expect(results.total_entries).to eq(38)
|
216
216
|
|
217
|
-
results.length.
|
218
|
-
results[0].
|
219
|
-
results[0].ListPrice.
|
217
|
+
expect(results.length).to eq(8)
|
218
|
+
expect(results[0]).to be_a(subject)
|
219
|
+
expect(results[0].ListPrice).to eq(50000.0)
|
220
220
|
end
|
221
221
|
|
222
222
|
end
|
@@ -18,12 +18,12 @@ describe SparkApi::PrimaryArray do
|
|
18
18
|
d = PrimaryModel.new(4, true)
|
19
19
|
e = PrimaryModel.new(5)
|
20
20
|
tester = subject.class.new([d,e])
|
21
|
-
tester.primary.
|
21
|
+
expect(tester.primary).to eq(d)
|
22
22
|
tester = subject.class.new([a,b,c,d,e])
|
23
|
-
tester.primary.
|
23
|
+
expect(tester.primary).to eq(d)
|
24
24
|
# Note, it doesn't care if there is more than one primary, just returns first in the list.
|
25
25
|
b.Primary = true
|
26
|
-
tester.primary.
|
26
|
+
expect(tester.primary).to eq(b)
|
27
27
|
end
|
28
28
|
it "should return nil when there is no primary element" do
|
29
29
|
a = PrimaryModel.new(1)
|
@@ -32,9 +32,9 @@ describe SparkApi::PrimaryArray do
|
|
32
32
|
d = PrimaryModel.new(4)
|
33
33
|
e = PrimaryModel.new(5)
|
34
34
|
tester = subject.class.new([])
|
35
|
-
tester.primary.
|
35
|
+
expect(tester.primary).to be(nil)
|
36
36
|
tester = subject.class.new([a,b,c,d,e])
|
37
|
-
tester.primary.
|
37
|
+
expect(tester.primary).to be(nil)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -4,45 +4,45 @@ describe SparkApi do
|
|
4
4
|
describe SparkApi::ClientError do
|
5
5
|
subject { SparkApi::ClientError.new({:message=>"OMG FAIL", :code=>1234, :status=>500, :request_path => '/v1/foo', :request_id => 'deadbeef'}) }
|
6
6
|
it "should print a helpful to_s" do
|
7
|
-
subject.to_s.
|
8
|
-
subject.message.
|
7
|
+
expect(subject.to_s).to eq("OMG FAIL")
|
8
|
+
expect(subject.message).to eq("OMG FAIL")
|
9
9
|
end
|
10
10
|
it "should have an api code" do
|
11
|
-
subject.code.
|
11
|
+
expect(subject.code).to eq(1234)
|
12
12
|
end
|
13
13
|
it "should have an http status" do
|
14
|
-
subject.status.
|
14
|
+
expect(subject.status).to eq(500)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should have a request_path" do
|
18
|
-
subject.request_path.
|
18
|
+
expect(subject.request_path).to eq('/v1/foo')
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should have a request_id" do
|
22
|
-
subject.request_id.
|
22
|
+
expect(subject.request_id).to eq('deadbeef')
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should raise and exception with attached message" do
|
26
26
|
expect { raise subject.class, {:message=>"My Message", :code=>1000, :status=>404}}.to raise_error(SparkApi::ClientError) do |e|
|
27
|
-
e.message.
|
28
|
-
e.code.
|
29
|
-
e.status.
|
27
|
+
expect(e.message).to eq("My Message")
|
28
|
+
expect(e.code).to eq(1000)
|
29
|
+
expect(e.status).to eq(404)
|
30
30
|
end
|
31
31
|
expect { raise subject.class.new({:message=>"My Message", :code=>1000, :status=>404}) }.to raise_error(SparkApi::ClientError) do |e|
|
32
|
-
e.message.
|
33
|
-
e.code.
|
34
|
-
e.status.
|
32
|
+
expect(e.message).to eq("My Message")
|
33
|
+
expect(e.code).to eq(1000)
|
34
|
+
expect(e.status).to eq(404)
|
35
35
|
end
|
36
36
|
expect { raise subject.class.new({:code=>1000, :status=>404}), "My Message"}.to raise_error(SparkApi::ClientError) do |e|
|
37
|
-
e.message.
|
38
|
-
e.code.
|
39
|
-
e.status.
|
37
|
+
expect(e.message).to eq("My Message")
|
38
|
+
expect(e.code).to eq(1000)
|
39
|
+
expect(e.status).to eq(404)
|
40
40
|
end
|
41
41
|
expect { raise subject.class, "My Message"}.to raise_error(SparkApi::ClientError) do |e|
|
42
|
-
e.message.
|
43
|
-
e.code.
|
44
|
-
e.status.
|
45
|
-
e.request_id.
|
42
|
+
expect(e.message).to eq("My Message")
|
43
|
+
expect(e.code).to eq(nil)
|
44
|
+
expect(e.status).to eq(nil)
|
45
|
+
expect(e.request_id).to eq(nil)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -54,34 +54,34 @@ describe SparkApi do
|
|
54
54
|
end
|
55
55
|
it "should have results when successful" do
|
56
56
|
r = SparkApi::ApiResponse.new({"D"=>{"Success" => true, "Results" => []}})
|
57
|
-
r.success
|
58
|
-
r.results.empty
|
59
|
-
r.request_id.
|
57
|
+
expect(r.success?).to be(true)
|
58
|
+
expect(r.results.empty?).to be(true)
|
59
|
+
expect(r.request_id).to eq nil
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return the request_id" do
|
63
63
|
r = SparkApi::ApiResponse.new({"D"=>{"Success" => true, "Results" => []}}, 'foobar')
|
64
|
-
r.success
|
65
|
-
r.request_id.
|
64
|
+
expect(r.success?).to be(true)
|
65
|
+
expect(r.request_id).to eq('foobar')
|
66
66
|
end
|
67
67
|
it "should have a message on error" do
|
68
68
|
r = SparkApi::ApiResponse.new({"D"=>{"Success" => false, "Message" => "I am a failure."}})
|
69
|
-
r.success
|
70
|
-
r.message.
|
69
|
+
expect(r.success?).to be(false)
|
70
|
+
expect(r.message).to eq("I am a failure.")
|
71
71
|
end
|
72
72
|
it "should have SparkQLErrors when present" do
|
73
73
|
err = {"Token" => "ExpirationDate", "Status" => "Dropped"}
|
74
74
|
r = SparkApi::ApiResponse.new({"D"=>{"Success" => false, "Message" => "I am a failure from .",
|
75
75
|
"SparkQLErrors" => [err]
|
76
76
|
}})
|
77
|
-
r.sparkql_errors.first.
|
77
|
+
expect(r.sparkql_errors.first).to eq(err)
|
78
78
|
end
|
79
79
|
it "should have Errors when present" do
|
80
80
|
err = {"Type" => "InvalidAttribute", "Attribute" => "DisplayName", "Message" => "DisplayName is wrong."}
|
81
81
|
r = SparkApi::ApiResponse.new({"D"=>{"Success" => false, "Message" => "I am a failure from .",
|
82
82
|
"Errors" => [err]
|
83
83
|
}})
|
84
|
-
r.errors.first.
|
84
|
+
expect(r.errors.first).to eq(err)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -193,59 +193,59 @@ describe SparkApi do
|
|
193
193
|
r
|
194
194
|
end
|
195
195
|
it "should get a service" do
|
196
|
-
subject.get('/system')[0]["Name"].
|
196
|
+
expect(subject.get('/system')[0]["Name"]).to eq("My User")
|
197
197
|
end
|
198
198
|
it "should get a service with parameters" do
|
199
|
-
subject.get('/marketstatistics/price', "Options" => "ActiveAverageListPrice")[0]["ActiveAverageListPrice"].
|
199
|
+
expect(subject.get('/marketstatistics/price', "Options" => "ActiveAverageListPrice")[0]["ActiveAverageListPrice"]).to eq([100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000])
|
200
200
|
end
|
201
201
|
it "should post to a service" do
|
202
202
|
data = {"Contacts" => [{"DisplayName"=>"Wades Contact","PrimaryEmail"=>"wade11@fbsdata.com"}]}
|
203
|
-
subject.post('/contacts', data)[0]["ResourceUri"].
|
203
|
+
expect(subject.post('/contacts', data)[0]["ResourceUri"]).to eq("1000")
|
204
204
|
end
|
205
205
|
it "should put to a service" do
|
206
206
|
# This is a hypothetical unsupported service action at this time
|
207
207
|
data = {"Contacts" => [{"DisplayName"=>"WLMCEWENS Contact","PrimaryEmail"=>"wlmcewen789@fbsdata.com"}]}
|
208
|
-
subject.put('/contacts/1000', data).size.
|
208
|
+
expect(subject.put('/contacts/1000', data).size).to be(0)
|
209
209
|
# No validation here, if no error is raised, everything is hunky dory
|
210
210
|
end
|
211
211
|
it "should delete from a service" do
|
212
212
|
# This is a hypothetical unsupported service action at this time
|
213
|
-
subject.delete('/contacts/1000').size.
|
213
|
+
expect(subject.delete('/contacts/1000').size).to be(0)
|
214
214
|
# No validation here, if no error is raised, everything is hunky dory
|
215
215
|
end
|
216
216
|
|
217
217
|
it "should escape a path correctly" do
|
218
|
-
subject.get('/test path with spaces').length.
|
218
|
+
expect(subject.get('/test path with spaces').length).to eq(0)
|
219
219
|
# now try this with an already escaped path. Kaboom!
|
220
220
|
expect { subject.get('/test%20path%20with%20spaces') }.to raise_error()
|
221
221
|
end
|
222
222
|
|
223
223
|
it "post data should support non json data" do
|
224
224
|
# Other MISC requests
|
225
|
-
subject.post('/stringdata', 'I am a lonely String!').success
|
225
|
+
expect(subject.post('/stringdata', 'I am a lonely String!').success?).to eq(true)
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should support arrays in the body" do
|
229
|
-
subject.put('/arraydata', ["A","B","C"]).success
|
229
|
+
expect(subject.put('/arraydata', ["A","B","C"]).success?).to be true
|
230
230
|
end
|
231
231
|
|
232
232
|
it "should allow response object to be returned instead of body" do
|
233
233
|
r = subject.get('/system', { full_response: true })
|
234
234
|
|
235
|
-
r.is_a?(Faraday::Response).
|
236
|
-
r.status.
|
235
|
+
expect(r.is_a?(Faraday::Response)).to be(true)
|
236
|
+
expect(r.status).to eq(200)
|
237
237
|
end
|
238
238
|
|
239
239
|
it "should give me BigDecimal results for large floating point numbers" do
|
240
|
-
MultiJson.default_adapter.
|
240
|
+
expect(MultiJson.default_adapter).to eq(:yajl) unless jruby?
|
241
241
|
result = subject.get('/listings/1000')[0]
|
242
|
-
result["StandardFields"]["BuildingAreaTotal"].
|
243
|
-
|
244
|
-
result["StandardFields"]["BuildingAreaTotal"].
|
242
|
+
expect(result["StandardFields"]["BuildingAreaTotal"]).to be_a(Float)
|
243
|
+
skip("our JSON parser does not support large decimal types. Anyone feel like writing some c code?") do
|
244
|
+
expect(result["StandardFields"]["BuildingAreaTotal"]).to be_a(BigDecimal)
|
245
245
|
number = BigDecimal.new(result["StandardFields"]["BuildingAreaTotal"].to_s)
|
246
|
-
number.to_s.
|
246
|
+
expect(number.to_s).to eq(BigDecimal.new("0.000000000000000000000000001").to_s)
|
247
247
|
number = BigDecimal.new(result["StandardFields"]["ListPrice"].to_s)
|
248
|
-
number.to_s.
|
248
|
+
expect(number.to_s).to eq(BigDecimal.new("9999999999999999999999999.99").to_s)
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
@@ -279,11 +279,11 @@ describe SparkApi do
|
|
279
279
|
r
|
280
280
|
end
|
281
281
|
it "should authenticate and then get a service" do
|
282
|
-
subject.get('/system')[0]["Name"].
|
282
|
+
expect(subject.get('/system')[0]["Name"]).to eq("My User")
|
283
283
|
end
|
284
284
|
it "should authenticate and then post to a service" do
|
285
285
|
data = {"Contacts" => [{"DisplayName"=>"Wades Contact","PrimaryEmail"=>"wade11@fbsdata.com"}]}
|
286
|
-
subject.post('/contacts', data)[0]["ResourceUri"].
|
286
|
+
expect(subject.post('/contacts', data)[0]["ResourceUri"]).to eq("1000")
|
287
287
|
end
|
288
288
|
end
|
289
289
|
|
@@ -322,13 +322,13 @@ describe SparkApi do
|
|
322
322
|
r
|
323
323
|
end
|
324
324
|
it "should reauthenticate and then get a service" do
|
325
|
-
subject.get('/system')[0]["Name"].
|
326
|
-
subject.reauthenticated
|
325
|
+
expect(subject.get('/system')[0]["Name"]).to eq("My User")
|
326
|
+
expect(subject.reauthenticated?).to eq(true)
|
327
327
|
end
|
328
328
|
it "should reauthenticate and then post to a service" do
|
329
329
|
data = {"Contacts" => [{"DisplayName"=>"Wades Contact","PrimaryEmail"=>"wade11@fbsdata.com"}]}
|
330
|
-
subject.post('/contacts', data)[0]["ResourceUri"].
|
331
|
-
subject.reauthenticated
|
330
|
+
expect(subject.post('/contacts', data)[0]["ResourceUri"]).to eq("1000")
|
331
|
+
expect(subject.reauthenticated?).to eq(true)
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
@@ -340,13 +340,13 @@ describe SparkApi do
|
|
340
340
|
r
|
341
341
|
end
|
342
342
|
it "should reauthenticate and then get a service" do
|
343
|
-
subject.get('/system')[0]["Name"].
|
344
|
-
subject.reauthenticated
|
343
|
+
expect(subject.get('/system')[0]["Name"]).to eq("My User")
|
344
|
+
expect(subject.reauthenticated?).to eq(true)
|
345
345
|
end
|
346
346
|
it "should reauthenticate and then post to a service" do
|
347
347
|
data = {"Contacts" => [{"DisplayName"=>"Wades Contact","PrimaryEmail"=>"wade11@fbsdata.com"}]}
|
348
|
-
subject.post('/contacts', data)[0]["ResourceUri"].
|
349
|
-
subject.reauthenticated
|
348
|
+
expect(subject.post('/contacts', data)[0]["ResourceUri"]).to eq("1000")
|
349
|
+
expect(subject.reauthenticated?).to eq(true)
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
@@ -384,19 +384,19 @@ describe SparkApi do
|
|
384
384
|
end
|
385
385
|
it "should fail horribly on a get" do
|
386
386
|
expect { subject.get('/system')}.to raise_error(SparkApi::PermissionDenied) do |e|
|
387
|
-
e.code.
|
388
|
-
e.request_path.
|
387
|
+
expect(e.code).to eq(SparkApi::ResponseCodes::SESSION_TOKEN_EXPIRED)
|
388
|
+
expect(e.request_path.to_s).to match(/\/system/)
|
389
389
|
end
|
390
|
-
subject.reauthenticated.
|
390
|
+
expect(subject.reauthenticated).to eq(2)
|
391
391
|
|
392
392
|
end
|
393
393
|
it "should fail horribly on a post" do
|
394
394
|
data = {"Contacts" => [{"DisplayName"=>"Wades Contact","PrimaryEmail"=>"wade11@fbsdata.com"}]}
|
395
395
|
expect { subject.post('/contacts', data)}.to raise_error(SparkApi::PermissionDenied) do |e|
|
396
|
-
e.code.
|
397
|
-
e.request_path.
|
396
|
+
expect(e.code).to eq(SparkApi::ResponseCodes::SESSION_TOKEN_EXPIRED)
|
397
|
+
expect(e.request_path.to_s).to match(/\/contacts/)
|
398
398
|
end
|
399
|
-
subject.reauthenticated.
|
399
|
+
expect(subject.reauthenticated).to eq(2)
|
400
400
|
end
|
401
401
|
end
|
402
402
|
|