vhx-ruby 0.0.7 → 0.0.8
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 +4 -1
- data/lib/vhx.rb +4 -3
- data/lib/vhx/client.rb +6 -3
- data/lib/vhx/objects/analytics.rb +9 -0
- data/lib/vhx/utilities/vhx_object.rb +2 -2
- data/lib/vhx/version.rb +2 -2
- data/spec/client_spec.rb +44 -9
- data/spec/fixtures/sample_authorization_response.json +19 -0
- data/spec/fixtures/sample_collection_response.json +20 -0
- data/spec/fixtures/sample_collections_response.json +14 -0
- data/spec/fixtures/sample_create_video_response.json +33 -0
- data/spec/fixtures/sample_customer_response.json +16 -0
- data/spec/fixtures/sample_customers_response.json +28 -0
- data/spec/fixtures/sample_files_response.json +16 -0
- data/spec/fixtures/sample_product_response.json +30 -0
- data/spec/fixtures/sample_products_response.json +14 -0
- data/spec/fixtures/sample_video_response.json +47 -31
- data/spec/fixtures/sample_videos_response.json +14 -0
- data/spec/middleware/error_response_spec.rb +3 -7
- data/spec/middleware/oauth2_spec.rb +3 -7
- data/spec/objects/analytics_spec.rb +41 -0
- data/spec/objects/authorization_spec.rb +58 -0
- data/spec/objects/collection_item_spec.rb +53 -0
- data/spec/objects/collection_spec.rb +66 -0
- data/spec/objects/customer_spec.rb +82 -0
- data/spec/objects/product_spec.rb +65 -0
- data/spec/objects/site_spec.rb +36 -27
- data/spec/objects/user_spec.rb +40 -32
- data/spec/objects/video_file_spec.rb +52 -0
- data/spec/objects/video_spec.rb +67 -23
- data/spec/spec_helper.rb +2 -11
- data/spec/utilities/vhx_helper_spec.rb +11 -7
- data/spec/utilities/vhx_list_object_spec.rb +27 -0
- data/spec/utilities/vhx_object_spec.rb +69 -26
- data/vhx.gemspec +4 -4
- metadata +59 -66
- data/spec/fixtures/sample_package_response.json +0 -185
- data/spec/objects/file_spec.rb +0 -29
- data/spec/objects/package_spec.rb +0 -74
- data/spec/test_data.rb +0 -55
- data/spec/utilities/vhx_collection_spec.rb +0 -27
- data/spec/vcr/Vhx_Client/application_user/_refresh_access_token/access_token_changed.yml +0 -57
- data/spec/vcr/Vhx_Client/application_user/_refresh_access_token/oauth_token_refreshed.yml +0 -57
- data/spec/vcr/Vhx_File/associations/are_present.yml +0 -409
- data/spec/vcr/Vhx_Middleware_ErrorResponse/unauthorized_user_credentials.yml +0 -122
- data/spec/vcr/Vhx_Middleware_OAuth2/access_token_refresh.yml +0 -797
- data/spec/vcr/Vhx_Package/_add_video/with_hypermedia/returns_package_object.yml +0 -51
- data/spec/vcr/Vhx_Package/_add_video/with_id/returns_package_object.yml +0 -51
- data/spec/vcr/Vhx_Package/_create/returns_package_object.yml +0 -140
- data/spec/vcr/Vhx_Package/_find/with_hypermedia.yml +0 -243
- data/spec/vcr/Vhx_Package/_find/with_id.yml +0 -243
- data/spec/vcr/Vhx_Package/_remove_video/with_hypermedia/returns_success.yml +0 -51
- data/spec/vcr/Vhx_Package/_remove_video/with_id/returns_success.yml +0 -51
- data/spec/vcr/Vhx_Package/associations/are_present.yml +0 -195
- data/spec/vcr/Vhx_Site/_create/returns_site_object.yml +0 -91
- data/spec/vcr/Vhx_Site/_find/with_hypermedia.yml +0 -195
- data/spec/vcr/Vhx_Site/_find/with_id.yml +0 -195
- data/spec/vcr/Vhx_User/_find/with_hypermedia.yml +0 -81
- data/spec/vcr/Vhx_User/_find/with_id.yml +0 -81
- data/spec/vcr/Vhx_User/_me/returns_user_object.yml +0 -720
- data/spec/vcr/Vhx_User/_update/returns_user_object.yml +0 -212
- data/spec/vcr/Vhx_VhxObject/associations/cache/retreive_if_available.yml +0 -195
- data/spec/vcr/Vhx_VhxObject/associations/falls_back_to_links.yml +0 -310
- data/spec/vcr/Vhx_Video/_create/returns_video_object.yml +0 -125
- data/spec/vcr/Vhx_Video/associations/are_present.yml +0 -294
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_links": {
|
|
3
|
+
"self": { "href": "https://api.vhx.tv/videos?page=1&query=term" },
|
|
4
|
+
"first": { "href": "https://api.vhx.tv/videos?query=term" },
|
|
5
|
+
"prev": { "href": null },
|
|
6
|
+
"next": { "href": "https://api.vhx.tv/videos?page=2&query=term" },
|
|
7
|
+
"last": { "href": "https://api.vhx.tv/videos?page=5&query=term" }
|
|
8
|
+
},
|
|
9
|
+
"count": 100,
|
|
10
|
+
"total": 500,
|
|
11
|
+
"_embedded": {
|
|
12
|
+
"videos": []
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Vhx::Middleware::ErrorResponse, :vcr do
|
|
4
|
-
|
|
5
|
-
Vhx.
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
it 'unauthorized_user_credentials' do
|
|
9
|
-
expect{Vhx::User.me}.to raise_error(Vhx::UnauthorizedError)
|
|
4
|
+
xit 'unauthorized_user_credentials' do
|
|
5
|
+
expect{Vhx::Customer.find(1)}.to raise_error(Vhx::UnauthorizedError)
|
|
10
6
|
end
|
|
11
|
-
end
|
|
7
|
+
end
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Vhx::Middleware::OAuth2, :vcr do
|
|
4
|
-
|
|
5
|
-
Vhx.setup(expired_credentials)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
it 'access_token refresh' do
|
|
4
|
+
xit 'access_token refresh' do
|
|
9
5
|
original_access_token = Vhx.client.oauth_token.access_token
|
|
10
6
|
Vhx::Client.any_instance.should_receive(:refresh_access_token!).and_call_original
|
|
11
|
-
Vhx::
|
|
7
|
+
Vhx::Customer.find(1)
|
|
12
8
|
expect(Vhx.client.oauth_token.access_token).to_not eq original_access_token
|
|
13
9
|
end
|
|
14
|
-
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Vhx::Analytics do
|
|
4
|
+
describe ".report" do
|
|
5
|
+
it "retrieves statistics from the /analytics endpoint" do
|
|
6
|
+
Vhx.setup(api_key: '-123131')
|
|
7
|
+
payload = {
|
|
8
|
+
"_links" => {
|
|
9
|
+
"self" => { "href" => "/analytics" },
|
|
10
|
+
},
|
|
11
|
+
"to" => "to",
|
|
12
|
+
"from" => "from",
|
|
13
|
+
"type" => "type",
|
|
14
|
+
"data" => {
|
|
15
|
+
"plays" => 10,
|
|
16
|
+
"seconds" => 60,
|
|
17
|
+
"finishes" => 9,
|
|
18
|
+
"video_id" => 1,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
query_params = {
|
|
22
|
+
"page" => "1",
|
|
23
|
+
"per_page" => "10",
|
|
24
|
+
}
|
|
25
|
+
stub_analytics(query_params: query_params, response: payload)
|
|
26
|
+
|
|
27
|
+
analytics = Vhx::Analytics.report(query_params)
|
|
28
|
+
|
|
29
|
+
expect(analytics.to).to eq(payload.fetch("to"))
|
|
30
|
+
expect(analytics.from).to eq(payload.fetch("from"))
|
|
31
|
+
expect(analytics.type).to eq(payload.fetch("type"))
|
|
32
|
+
expect(analytics.data).to eq(payload.fetch("data"))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def stub_analytics(response:, query_params:)
|
|
37
|
+
stub_request(:get, %r{api.vhx.tv/analytics}).
|
|
38
|
+
with(query: hash_including(query_params)).
|
|
39
|
+
to_return(body: response.to_json)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Vhx::Authorization do
|
|
4
|
+
|
|
5
|
+
before{
|
|
6
|
+
Vhx.setup({api_key: 'testapikey'})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe 'api operations' do
|
|
10
|
+
|
|
11
|
+
describe '::find' do
|
|
12
|
+
it 'raises error' do
|
|
13
|
+
expect{Vhx::Authorization.find(123)}.to raise_error(NoMethodError)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '::retrieve' do
|
|
18
|
+
it 'raises error' do
|
|
19
|
+
expect{Vhx::Authorization.retrieve(123)}.to raise_error(NoMethodError)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '::list' do
|
|
24
|
+
it 'raises error' do
|
|
25
|
+
expect{Vhx::Authorization.list()}.to raise_error(NoMethodError)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '::all' do
|
|
30
|
+
it 'raises errors' do
|
|
31
|
+
expect{Vhx::Authorization.all()}.to raise_error(NoMethodError)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '::create' do
|
|
36
|
+
def authorization_response
|
|
37
|
+
JSON.parse(File.read("spec/fixtures/sample_authorization_response.json"))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'does not error' do
|
|
41
|
+
Vhx.connection.stub(:post).and_return(OpenStruct.new(body: authorization_response))
|
|
42
|
+
expect{Vhx::Authorization.create({})}.to_not raise_error
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#udpate' do
|
|
47
|
+
it 'raises error' do
|
|
48
|
+
expect{Vhx::Authorization.new({}).update}.to raise_error(NoMethodError)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '::delete' do
|
|
53
|
+
it 'raises error' do
|
|
54
|
+
expect{Vhx::Authorization.delete(1)}.to raise_error(NoMethodError)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Vhx::Collection::Item do
|
|
4
|
+
|
|
5
|
+
before{
|
|
6
|
+
Vhx.setup({api_key: 'testapikey'})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe 'api operations' do
|
|
10
|
+
|
|
11
|
+
describe '::find' do
|
|
12
|
+
it 'raises error' do
|
|
13
|
+
expect{Vhx::Collection::Item.find(123)}.to raise_error(NoMethodError)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '::retrieve' do
|
|
18
|
+
it 'raises error' do
|
|
19
|
+
expect{Vhx::Collection::Item.retrieve(123)}.to raise_error(NoMethodError)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '::list' do
|
|
24
|
+
it 'raises error' do
|
|
25
|
+
expect{Vhx::Collection::Item.list()}.to raise_error(NoMethodError)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '::all' do
|
|
30
|
+
it 'raises errors' do
|
|
31
|
+
expect{Vhx::Collection::Item.all()}.to raise_error(NoMethodError)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '::create' do
|
|
36
|
+
it 'raises error' do
|
|
37
|
+
expect{Vhx::Collection::Item.create()}.to raise_error(NoMethodError)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe '#udpate' do
|
|
42
|
+
it 'raises error' do
|
|
43
|
+
expect{Vhx::Collection::Item.new({}).update}.to raise_error(NoMethodError)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '::delete' do
|
|
48
|
+
it 'raises error' do
|
|
49
|
+
expect{Vhx::Collection::Item.delete(1)}.to raise_error(NoMethodError)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Vhx::Collection do
|
|
4
|
+
def collection_response
|
|
5
|
+
JSON.parse(File.read("spec/fixtures/sample_collection_response.json"))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def collections_response
|
|
9
|
+
JSON.parse(File.read("spec/fixtures/sample_collections_response.json"))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before{
|
|
13
|
+
Vhx.setup({api_key: 'testapikey'})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe 'api operations' do
|
|
17
|
+
|
|
18
|
+
describe '::find' do
|
|
19
|
+
it 'does not error' do
|
|
20
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: collection_response))
|
|
21
|
+
expect{Vhx::Collection.find(123)}.to_not raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '::retrieve' do
|
|
26
|
+
it 'does not error' do
|
|
27
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: collection_response))
|
|
28
|
+
expect{Vhx::Collection.retrieve(123)}.to_not raise_error
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '::list' do
|
|
33
|
+
it 'does not error' do
|
|
34
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: collections_response))
|
|
35
|
+
expect{Vhx::Collection.list()}.to_not raise_error
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '::all' do
|
|
40
|
+
it 'does not error' do
|
|
41
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: collections_response))
|
|
42
|
+
expect{Vhx::Collection.all()}.to_not raise_error
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '::create' do
|
|
47
|
+
it 'does not error' do
|
|
48
|
+
Vhx.connection.stub(:post).and_return(OpenStruct.new(body: collections_response))
|
|
49
|
+
expect{Vhx::Collection.create({})}.to_not raise_error
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#udpate' do
|
|
54
|
+
it 'does not error' do
|
|
55
|
+
Vhx.connection.stub(:put).and_return(OpenStruct.new(body: collections_response))
|
|
56
|
+
expect{Vhx::Collection.new(collection_response).update({})}.to_not raise_error
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '::delete' do
|
|
61
|
+
it 'raises error' do
|
|
62
|
+
expect{Vhx::Collection.delete(1)}.to raise_error(NoMethodError)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Vhx::Customer do
|
|
4
|
+
def customer_response
|
|
5
|
+
JSON.parse(File.read("spec/fixtures/sample_customer_response.json"))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def customers_response
|
|
9
|
+
JSON.parse(File.read("spec/fixtures/sample_customers_response.json"))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before{
|
|
13
|
+
Vhx.setup({api_key: 'testapikey'})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe 'api operations' do
|
|
17
|
+
|
|
18
|
+
describe '::find' do
|
|
19
|
+
it 'does not error' do
|
|
20
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: customer_response))
|
|
21
|
+
expect{Vhx::Customer.find(123)}.to_not raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '::retrieve' do
|
|
26
|
+
it 'does not error' do
|
|
27
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: customer_response))
|
|
28
|
+
expect{Vhx::Customer.retrieve(123)}.to_not raise_error
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '::list' do
|
|
33
|
+
it 'does not error' do
|
|
34
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: customers_response))
|
|
35
|
+
expect{Vhx::Customer.list()}.to_not raise_error
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '::all' do
|
|
40
|
+
it 'does not error' do
|
|
41
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: customers_response))
|
|
42
|
+
expect{Vhx::Customer.all()}.to_not raise_error
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '::create' do
|
|
47
|
+
it 'does not error' do
|
|
48
|
+
Vhx.connection.stub(:post).and_return(OpenStruct.new(body: customers_response))
|
|
49
|
+
expect{Vhx::Customer.create({})}.to_not raise_error
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#udpate' do
|
|
54
|
+
it 'raises error' do
|
|
55
|
+
expect{Vhx::Customer.new(customer_response).update}.to raise_error(NoMethodError)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe '::delete' do
|
|
60
|
+
it 'does not error' do
|
|
61
|
+
Vhx.connection.stub(:delete).and_return(OpenStruct.new(body: ""))
|
|
62
|
+
expect{Vhx::Customer.delete(1)}.to_not raise_error
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '#add_product' do
|
|
67
|
+
it 'returns customer' do
|
|
68
|
+
Vhx.connection.stub(:put).and_return(OpenStruct.new(body: customer_response))
|
|
69
|
+
customer = Vhx::Customer.new(customer_response).add_product(1)
|
|
70
|
+
expect(customer.class).to eq(Vhx::Customer)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '#remove_product' do
|
|
75
|
+
it 'returns customer' do
|
|
76
|
+
Vhx.connection.stub(:delete).and_return(OpenStruct.new(body: customer_response))
|
|
77
|
+
customer = Vhx::Customer.new(customer_response).remove_product(1)
|
|
78
|
+
expect(customer.class).to eq(Vhx::Customer)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Vhx::Product do
|
|
4
|
+
|
|
5
|
+
def product_response
|
|
6
|
+
JSON.parse(File.read("spec/fixtures/sample_product_response.json"))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def products_response
|
|
10
|
+
JSON.parse(File.read("spec/fixtures/sample_products_response.json"))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
before{
|
|
14
|
+
Vhx.setup({api_key: 'testapikey'})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe 'api operations' do
|
|
18
|
+
|
|
19
|
+
describe '::find' do
|
|
20
|
+
it 'does not error' do
|
|
21
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: product_response))
|
|
22
|
+
expect{Vhx::Product.find(123)}.to_not raise_error
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe '::retrieve' do
|
|
27
|
+
it 'does not error' do
|
|
28
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: product_response))
|
|
29
|
+
expect{Vhx::Product.retrieve(123)}.to_not raise_error
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '::list' do
|
|
34
|
+
it 'does not error' do
|
|
35
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: products_response))
|
|
36
|
+
expect{Vhx::Product.list()}.to_not raise_error
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '::all' do
|
|
41
|
+
it 'does not error' do
|
|
42
|
+
Vhx.connection.stub(:get).and_return(OpenStruct.new(body: products_response))
|
|
43
|
+
expect{Vhx::Product.all()}.to_not raise_error
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe '::create' do
|
|
48
|
+
it 'raises error' do
|
|
49
|
+
expect{Vhx::Product.create()}.to raise_error(NoMethodError)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#udpate' do
|
|
54
|
+
it 'raises error' do
|
|
55
|
+
expect{Vhx::Product.new({}).update}.to raise_error(NoMethodError)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe '::delete' do
|
|
60
|
+
it 'raises error' do
|
|
61
|
+
expect{Vhx::Product.delete(1)}.to raise_error(NoMethodError)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
data/spec/objects/site_spec.rb
CHANGED
|
@@ -1,44 +1,53 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Vhx::Site
|
|
4
|
-
let(:sample_site_response){ JSON.parse(File.read("spec/fixtures/sample_site_response.json")) }
|
|
5
|
-
let(:vhx_site){Vhx::Site.new(sample_site_response)}
|
|
3
|
+
describe Vhx::Site do
|
|
6
4
|
|
|
7
|
-
before
|
|
8
|
-
Vhx.setup(
|
|
5
|
+
before{
|
|
6
|
+
Vhx.setup({api_key: 'testapikey'})
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
describe '
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
describe 'api operations' do
|
|
10
|
+
|
|
11
|
+
describe '::find' do
|
|
12
|
+
it 'raises error' do
|
|
13
|
+
expect{Vhx::Site.find(123)}.to raise_error(NoMethodError)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '::retrieve' do
|
|
18
|
+
it 'raises error' do
|
|
19
|
+
expect{Vhx::Site.retrieve(123)}.to raise_error(NoMethodError)
|
|
20
|
+
end
|
|
14
21
|
end
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
describe '::list' do
|
|
24
|
+
it 'raises error' do
|
|
25
|
+
expect{Vhx::Site.list()}.to raise_error(NoMethodError)
|
|
26
|
+
end
|
|
18
27
|
end
|
|
19
|
-
end
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
describe '::all' do
|
|
30
|
+
it 'raises errors' do
|
|
31
|
+
expect{Vhx::Site.all()}.to raise_error(NoMethodError)
|
|
32
|
+
end
|
|
25
33
|
end
|
|
26
|
-
end
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
describe '::create' do
|
|
36
|
+
it 'raises error' do
|
|
37
|
+
expect{Vhx::Site.create()}.to raise_error(NoMethodError)
|
|
38
|
+
end
|
|
32
39
|
end
|
|
33
|
-
end
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
describe '#udpate' do
|
|
42
|
+
it 'raises error' do
|
|
43
|
+
expect{Vhx::Site.new({}).update}.to raise_error(NoMethodError)
|
|
44
|
+
end
|
|
38
45
|
end
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
describe '::delete' do
|
|
48
|
+
it 'raises error' do
|
|
49
|
+
expect{Vhx::Site.delete(1)}.to raise_error(NoMethodError)
|
|
50
|
+
end
|
|
42
51
|
end
|
|
43
52
|
end
|
|
44
|
-
end
|
|
53
|
+
end
|