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
@@ -10,9 +10,9 @@ describe QuickSearch do
|
|
10
10
|
it "gets a current user's quick searches" do
|
11
11
|
s = stub_api_get("/searchtemplates/quicksearches", "search_templates/quick_searches/get.json")
|
12
12
|
quicksearches = QuickSearch.get
|
13
|
-
quicksearches.
|
14
|
-
quicksearches.size.
|
15
|
-
s.
|
13
|
+
expect(quicksearches).to be_an(Array)
|
14
|
+
expect(quicksearches.size).to eq(2)
|
15
|
+
expect(s).to have_been_requested
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -21,8 +21,8 @@ describe QuickSearch do
|
|
21
21
|
it "gets an individual quick search" do
|
22
22
|
s = stub_api_get("/searchtemplates/quicksearches/#{id}", "search_templates/quick_searches/get.json")
|
23
23
|
quicksearch = QuickSearch.find(id)
|
24
|
-
quicksearch.
|
25
|
-
s.
|
24
|
+
expect(quicksearch).to be_an(QuickSearch)
|
25
|
+
expect(s).to have_been_requested
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -7,7 +7,7 @@ describe SharedListing do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should respond to the finders" do
|
10
|
-
SharedListing.
|
10
|
+
expect(SharedListing).to respond_to(:find)
|
11
11
|
end
|
12
12
|
|
13
13
|
context "/sharedlistings", :support do
|
@@ -15,11 +15,11 @@ describe SharedListing do
|
|
15
15
|
stub_api_post("/#{subject.class.element_name}", 'listings/shared_listing_new.json', 'listings/shared_listing_post.json')
|
16
16
|
subject.ListingIds = ["20110224152431857619000000","20110125122333785431000000"]
|
17
17
|
subject.ViewId = "20080125122333787615000000"
|
18
|
-
subject.save.
|
19
|
-
subject.Id.
|
20
|
-
subject.Mode.
|
21
|
-
subject.ResourceUri.
|
22
|
-
subject.SharedUri.
|
18
|
+
expect(subject.save).to be(true)
|
19
|
+
expect(subject.Id).to eq("15Ar")
|
20
|
+
expect(subject.Mode).to eq("Public")
|
21
|
+
expect(subject.ResourceUri).to eq("/v1/sharedlistings/15Ar")
|
22
|
+
expect(subject.SharedUri).to eq("http://www.flexmls.com/share/15Ar/3544-N-Olsen-Avenue-Tucson-AZ-85719")
|
23
23
|
end
|
24
24
|
|
25
25
|
on_post_it "should fail creating" do
|
@@ -27,8 +27,8 @@ describe SharedListing do
|
|
27
27
|
request.to_return(:status => 400, :body => fixture('errors/failure.json'))
|
28
28
|
end
|
29
29
|
subject
|
30
|
-
subject.save.
|
31
|
-
expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
30
|
+
expect(subject.save).to be(false)
|
31
|
+
expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(400) }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -39,10 +39,10 @@ describe SharedListing do
|
|
39
39
|
'listings/shared_listing_get.json')
|
40
40
|
|
41
41
|
shared = SharedListing.find(shared_id)
|
42
|
-
shared.
|
43
|
-
shared.
|
44
|
-
shared.Mode.
|
45
|
-
shared.ListingIds.
|
42
|
+
expect(shared).to respond_to('SharedUri')
|
43
|
+
expect(shared).to respond_to('Mode')
|
44
|
+
expect(shared.Mode).to eq('Public')
|
45
|
+
expect(shared.ListingIds).to be_an(Array)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -6,14 +6,14 @@ describe Sort do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should include the finders module" do
|
9
|
-
Sort.
|
9
|
+
expect(Sort).to respond_to(:find)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should return sorts" do
|
13
13
|
stub_api_get("/searchtemplates/sorts", 'sorts/get.json')
|
14
14
|
sorts = Sort.find(:all)
|
15
|
-
sorts.
|
16
|
-
sorts.length.
|
15
|
+
expect(sorts).to be_an(Array)
|
16
|
+
expect(sorts.length).to eq(1)
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -7,11 +7,11 @@ describe StandardFields do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should respond to get" do
|
10
|
-
StandardFields.
|
10
|
+
expect(StandardFields).to respond_to(:get)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should find and expand all" do
|
14
|
-
StandardFields.
|
14
|
+
expect(StandardFields).to respond_to(:find_and_expand_all)
|
15
15
|
|
16
16
|
# stub request to standardFields
|
17
17
|
stub_api_get('/standardfields','standardfields/standardfields.json')
|
@@ -26,19 +26,19 @@ describe StandardFields do
|
|
26
26
|
fields = StandardFields.find_and_expand_all(["City","StateOrProvince"])
|
27
27
|
|
28
28
|
# keys are present
|
29
|
-
fields.
|
30
|
-
fields.
|
31
|
-
fields.
|
29
|
+
expect(fields).to have_key("City")
|
30
|
+
expect(fields).to have_key("StateOrProvince")
|
31
|
+
expect(fields).not_to have_key("SubdivisionName")
|
32
32
|
|
33
33
|
# FieldList
|
34
|
-
fields["City"]["FieldList"].length.
|
35
|
-
fields["StateOrProvince"]["FieldList"].length.
|
34
|
+
expect(fields["City"]["FieldList"].length).to eq(235)
|
35
|
+
expect(fields["StateOrProvince"]["FieldList"].length).to eq(5)
|
36
36
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context "/standardfields/nearby/<property_type>", :support do
|
40
40
|
on_get_it "should find nearby fields" do
|
41
|
-
StandardFields.
|
41
|
+
expect(StandardFields).to respond_to(:find_nearby)
|
42
42
|
|
43
43
|
# stub request
|
44
44
|
stub_api_get('/standardfields/nearby/A','standardfields/nearby.json',
|
@@ -50,10 +50,10 @@ describe StandardFields do
|
|
50
50
|
fields = StandardFields.find_nearby(["A"], {:Lat => 50, :Lon => -92})
|
51
51
|
|
52
52
|
# validate response
|
53
|
-
fields["D"]["Success"].
|
54
|
-
fields["D"]["Results"].first.
|
55
|
-
fields["D"]["Results"].first.
|
56
|
-
fields["D"]["Results"].first.
|
53
|
+
expect(fields["D"]["Success"]).to eq(true)
|
54
|
+
expect(fields["D"]["Results"].first).to have_key("City")
|
55
|
+
expect(fields["D"]["Results"].first).to have_key("PostalCode")
|
56
|
+
expect(fields["D"]["Results"].first).to have_key("StateOrProvince")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -17,14 +17,14 @@ describe Subresource do
|
|
17
17
|
|
18
18
|
dummy_class.parse_date_start_and_end_times(times)
|
19
19
|
|
20
|
-
times['Date'].
|
20
|
+
expect(times['Date']).to eq(date)
|
21
21
|
|
22
22
|
if RUBY_VERSION < '1.9'
|
23
|
-
times['StartTime'].
|
24
|
-
times['EndTime'].
|
23
|
+
expect(times['StartTime']).to eq(Time.parse(start_time.to_s))
|
24
|
+
expect(times['EndTime']).to eq(Time.parse(end_time.to_s))
|
25
25
|
else
|
26
|
-
times['StartTime'].
|
27
|
-
times['EndTime'].
|
26
|
+
expect(times['StartTime']).to eq(start_time.to_time)
|
27
|
+
expect(times['EndTime']).to eq(end_time.to_time)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -36,14 +36,14 @@ describe Subresource do
|
|
36
36
|
|
37
37
|
dummy_class.parse_date_start_and_end_times(times)
|
38
38
|
|
39
|
-
times['Date'].
|
39
|
+
expect(times['Date']).to eq(date)
|
40
40
|
|
41
41
|
if RUBY_VERSION < '1.9'
|
42
|
-
times['StartTime'].
|
43
|
-
times['EndTime'].
|
42
|
+
expect(times['StartTime']).to eq(Time.parse(start_time.to_s))
|
43
|
+
expect(times['EndTime']).to eq(Time.parse(end_time.to_s))
|
44
44
|
else
|
45
|
-
times['StartTime'].
|
46
|
-
times['EndTime'].
|
45
|
+
expect(times['StartTime']).to eq(start_time.to_time)
|
46
|
+
expect(times['EndTime']).to eq(end_time.to_time)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -55,14 +55,14 @@ describe Subresource do
|
|
55
55
|
|
56
56
|
dummy_class.parse_date_start_and_end_times(times)
|
57
57
|
|
58
|
-
times['Date'].
|
58
|
+
expect(times['Date']).to eq(date)
|
59
59
|
|
60
60
|
if RUBY_VERSION < '1.9'
|
61
|
-
times['StartTime'].
|
62
|
-
times['EndTime'].
|
61
|
+
expect(times['StartTime']).to eq(Time.parse(start_time.to_s))
|
62
|
+
expect(times['EndTime']).to eq(Time.parse(end_time.to_s))
|
63
63
|
else
|
64
|
-
times['StartTime'].
|
65
|
-
times['EndTime'].
|
64
|
+
expect(times['StartTime']).to eq(start_time.to_time)
|
65
|
+
expect(times['EndTime']).to eq(end_time.to_time)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -71,4 +71,22 @@ describe Subresource do
|
|
71
71
|
|
72
72
|
expect {dummy_class.parse_date_start_and_end_times(times)}.to raise_error(ArgumentError)
|
73
73
|
end
|
74
|
+
|
75
|
+
it "should ignore an empty Date" do
|
76
|
+
times = {'Date' => '', 'StartTime' => '09:12:34-0700', 'EndTime' => '12:43:21-0700'}
|
77
|
+
dummy_class.parse_date_start_and_end_times(times)
|
78
|
+
expect(times['Date']).to eq('')
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should ignore an empty StartTime" do
|
82
|
+
times = {'Date' => '10/01/2012', 'StartTime' => '', 'EndTime' => '12:43:21-0700'}
|
83
|
+
dummy_class.parse_date_start_and_end_times(times)
|
84
|
+
expect(times['StartTime']).to eq('')
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should ignore an empty EndTime" do
|
88
|
+
times = {'Date' => '10/01/2012', 'StartTime' => '09:12:34-0700', 'EndTime' => ''}
|
89
|
+
dummy_class.parse_date_start_and_end_times(times)
|
90
|
+
expect(times['EndTime']).to eq('')
|
91
|
+
end
|
74
92
|
end
|
@@ -16,22 +16,22 @@ describe SystemInfo do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should respond to get" do
|
19
|
-
SystemInfo.
|
19
|
+
expect(SystemInfo).to respond_to(:get)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should have a primary_logo instance method" do
|
23
|
-
@sysinfo.
|
23
|
+
expect(@sysinfo).to respond_to(:primary_logo)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should respond to attributes" do
|
27
27
|
['Name','OfficeId','Id','MlsId','Office','Mls'].each do |k|
|
28
|
-
(@sysinfo.send k.to_sym).
|
28
|
+
expect(@sysinfo.send k.to_sym).to be_a(String)
|
29
29
|
end
|
30
|
-
@sysinfo.Configuration.
|
30
|
+
expect(@sysinfo.Configuration).to be_a(Array)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should have an array of config items" do
|
34
|
-
@sysinfo.Configuration.
|
34
|
+
expect(@sysinfo.Configuration).to be_a(Array)
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#primary_logo" do
|
@@ -56,11 +56,11 @@ describe SystemInfo do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should return nil when no logo is present" do
|
59
|
-
@sysinfo.primary_logo.
|
59
|
+
expect(@sysinfo.primary_logo).to eq(nil)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should return the first logo when several are present" do
|
63
|
-
@sysinfo_with_logos.primary_logo.
|
63
|
+
expect(@sysinfo_with_logos.primary_logo).to be_a(Hash)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -16,7 +16,7 @@ describe TourOfHome do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should respond to a few methods" do
|
19
|
-
subject.class.
|
19
|
+
expect(subject.class).to respond_to(:find_by_listing_key)
|
20
20
|
end
|
21
21
|
|
22
22
|
context "/listings/<listing_id>/tourofhomes", :support do
|
@@ -24,8 +24,8 @@ describe TourOfHome do
|
|
24
24
|
stub_auth_request
|
25
25
|
stub_api_get('/listings/20060725224713296297000000/tourofhomes','listings/tour_of_homes.json')
|
26
26
|
v = subject.class.find_by_listing_key('20060725224713296297000000')
|
27
|
-
v.
|
28
|
-
v.length.
|
27
|
+
expect(v).to be_an(Array)
|
28
|
+
expect(v.length).to eq(2)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -3,16 +3,16 @@ require './spec/spec_helper'
|
|
3
3
|
describe Video do
|
4
4
|
|
5
5
|
it "responds to" do
|
6
|
-
Video.
|
7
|
-
Video.new.
|
8
|
-
Video.new.
|
6
|
+
expect(Video).to respond_to(:find_by_listing_key)
|
7
|
+
expect(Video.new).to respond_to(:branded?)
|
8
|
+
expect(Video.new).to respond_to(:unbranded?)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "has a type" do
|
12
|
-
Video.new(:Type => "branded").branded
|
13
|
-
Video.new(:Type => "unbranded").branded
|
14
|
-
Video.new(:Type => "unbranded").unbranded
|
15
|
-
Video.new(:Type => "branded").unbranded
|
12
|
+
expect(Video.new(:Type => "branded").branded?).to eq(true)
|
13
|
+
expect(Video.new(:Type => "unbranded").branded?).to eq(false)
|
14
|
+
expect(Video.new(:Type => "unbranded").unbranded?).to eq(true)
|
15
|
+
expect(Video.new(:Type => "branded").unbranded?).to eq(false)
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "/listings/<listing_id>/videos", :support do
|
@@ -23,8 +23,8 @@ describe Video do
|
|
23
23
|
|
24
24
|
on_get_it "should get an array of videos" do
|
25
25
|
p = Video.find_by_listing_key('1234')
|
26
|
-
p.
|
27
|
-
p.length.
|
26
|
+
expect(p).to be_an(Array)
|
27
|
+
expect(p.length).to eq(2)
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -12,14 +12,14 @@ describe VirtualTour do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should respond to a few methods" do
|
15
|
-
VirtualTour.
|
16
|
-
@virtualtour.
|
17
|
-
@virtualtour.
|
15
|
+
expect(VirtualTour).to respond_to(:find_by_listing_key)
|
16
|
+
expect(@virtualtour).to respond_to(:branded?)
|
17
|
+
expect(@virtualtour).to respond_to(:unbranded?)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should know if it's branded" do
|
21
|
-
@virtualtour.branded
|
22
|
-
@virtualtour.unbranded
|
21
|
+
expect(@virtualtour.branded?).to eq(true)
|
22
|
+
expect(@virtualtour.unbranded?).to eq(false)
|
23
23
|
end
|
24
24
|
|
25
25
|
context "/listings/<listing_id>/virtualtours", :support do
|
@@ -28,8 +28,8 @@ describe VirtualTour do
|
|
28
28
|
stub_api_get('/listings/1234/virtualtours','listings/virtual_tours_index.json')
|
29
29
|
|
30
30
|
v = VirtualTour.find_by_listing_key('1234')
|
31
|
-
v.
|
32
|
-
v.length.
|
31
|
+
expect(v).to be_an(Array)
|
32
|
+
expect(v.length).to eq(5)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -20,7 +20,7 @@ describe VowAccount do
|
|
20
20
|
})
|
21
21
|
vow.parent = Contact.new(:Id => "20090928182824338901000000")
|
22
22
|
vow.save
|
23
|
-
s.
|
23
|
+
expect(s).to have_been_requested
|
24
24
|
end
|
25
25
|
|
26
26
|
on_post_it "should create an empty consumer account" do
|
@@ -28,7 +28,7 @@ describe VowAccount do
|
|
28
28
|
vow = VowAccount.new
|
29
29
|
vow.parent = Contact.new(:Id => "20090928182824338901000000")
|
30
30
|
vow.save
|
31
|
-
s.
|
31
|
+
expect(s).to have_been_requested
|
32
32
|
end
|
33
33
|
|
34
34
|
on_put_it "should update a consumer account details" do
|
@@ -36,27 +36,27 @@ describe VowAccount do
|
|
36
36
|
@vow_account.LoginName = "Johnny Newman"
|
37
37
|
s = stub_api_put("/contacts/20090928182824338901000000/portal", "contacts/vow_accounts/edit.json", "contacts/vow_accounts/post.json")
|
38
38
|
@vow_account.save
|
39
|
-
s.
|
39
|
+
expect(s).to have_been_requested
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should enable the current account" do
|
43
43
|
s = stub_api_put("/contacts/20090928182824338901000000/portal", {"Settings" => {"Enabled" => "true"}}, "contacts/vow_accounts/post.json")
|
44
44
|
@vow_account.enable
|
45
|
-
@vow_account.enabled
|
46
|
-
s.
|
45
|
+
expect(@vow_account.enabled?).to be true
|
46
|
+
expect(s).to have_been_requested
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should disable the current account" do
|
50
50
|
s = stub_api_put("/contacts/20090928182824338901000000/portal", {"Settings" => {"Enabled" => "false"}}, "contacts/vow_accounts/post.json")
|
51
51
|
@vow_account.disable
|
52
|
-
@vow_account.enabled
|
53
|
-
s.
|
52
|
+
expect(@vow_account.enabled?).to be false
|
53
|
+
expect(s).to have_been_requested
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should change the password" do
|
57
57
|
s = stub_api_put("/contacts/20090928182824338901000000/portal", {"Password" => "NewPassw0rd123"}, "contacts/vow_accounts/post.json")
|
58
58
|
@vow_account.change_password("NewPassw0rd123")
|
59
|
-
s.
|
59
|
+
expect(s).to have_been_requested
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -20,13 +20,13 @@ describe SparkApi::MultiClient do
|
|
20
20
|
|
21
21
|
it "should activate a client implemenation when activate()" do
|
22
22
|
SparkApi.activate(:test_client_a)
|
23
|
-
SparkApi.client.api_key.
|
23
|
+
expect(SparkApi.client.api_key).to eq('a')
|
24
24
|
SparkApi.activate(:test_client_b)
|
25
|
-
SparkApi.client.api_key.
|
25
|
+
expect(SparkApi.client.api_key).to eq('b')
|
26
26
|
SparkApi.activate(:test_client_c)
|
27
|
-
SparkApi.client.api_key.
|
27
|
+
expect(SparkApi.client.api_key).to eq('c')
|
28
28
|
SparkApi.activate(:test_client_a)
|
29
|
-
SparkApi.client.api_key.
|
29
|
+
expect(SparkApi.client.api_key).to eq('a')
|
30
30
|
end
|
31
31
|
it "should fail to activate symbols that do not have implementations" do
|
32
32
|
expect { SparkApi.activate(:test_client_d) }.to raise_error(ArgumentError)
|
@@ -34,35 +34,35 @@ describe SparkApi::MultiClient do
|
|
34
34
|
|
35
35
|
it "should temporarily activate a client implemenation when activate() block" do
|
36
36
|
SparkApi.activate(:test_client_a)
|
37
|
-
SparkApi.client.api_key.
|
37
|
+
expect(SparkApi.client.api_key).to eq('a')
|
38
38
|
SparkApi.activate(:test_client_b) do
|
39
|
-
SparkApi.client.api_key.
|
39
|
+
expect(SparkApi.client.api_key).to eq('b')
|
40
40
|
end
|
41
|
-
SparkApi.client.api_key.
|
41
|
+
expect(SparkApi.client.api_key).to eq('a')
|
42
42
|
expect do
|
43
43
|
SparkApi.activate(:test_client_c) do
|
44
|
-
SparkApi.client.api_key.
|
44
|
+
expect(SparkApi.client.api_key).to eq('c')
|
45
45
|
raise "OH MY GOODNESS I BLEW UP!!!"
|
46
46
|
end
|
47
47
|
end.to raise_error
|
48
|
-
SparkApi.client.api_key.
|
48
|
+
expect(SparkApi.client.api_key).to eq('a')
|
49
49
|
end
|
50
50
|
|
51
51
|
context "yaml" do
|
52
52
|
before :each do
|
53
|
-
SparkApi::Configuration::YamlConfig.
|
53
|
+
allow(SparkApi::Configuration::YamlConfig).to receive(:config_path) { "spec/config/spark_api" }
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should activate a client implemenation when activate()" do
|
57
57
|
SparkApi.activate(:test_key)
|
58
|
-
SparkApi.client.api_key.
|
58
|
+
expect(SparkApi.client.api_key).to eq('demo_key')
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should activate a single session key" do
|
62
|
-
SparkApi::Configuration::YamlConfig.
|
62
|
+
allow(SparkApi::Configuration::YamlConfig).to receive(:config_path) { "spec/config/spark_api" }
|
63
63
|
SparkApi.activate(:test_single_session_oauth)
|
64
|
-
SparkApi.client.session.
|
65
|
-
SparkApi.client.session.access_token.
|
64
|
+
expect(SparkApi.client.session).to respond_to(:access_token)
|
65
|
+
expect(SparkApi.client.session.access_token).to eq("yay success!")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|