sentimeta 0.1.10 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/endpoint.yml +2 -2
- data/lib/sentimeta/version.rb +1 -1
- data/spec/client/auth_spec.rb +13 -0
- data/spec/client/data_spec.rb +15 -0
- data/spec/client/info_spec.rb +10 -0
- data/spec/client/prices_spec.rb +7 -0
- data/spec/client/subscription_spec.rb +8 -0
- data/spec/client/user_reviews_spec.rb +8 -0
- data/spec/client_spec.rb +0 -16
- data/spec/rest_client_spec.rb +86 -0
- data/spec/spec_helper.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6168306613bb2d06e0f3aa0120cb19816dacbc3
|
4
|
+
data.tar.gz: 7f3774c9ba5e107d35d327d6f362c21575569531
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4729be7f7803f539917049ef1e3d36207cfd06eaa726182e31c0c934a9f2b794f10f2c3a50a202283169a0af9620ae0d152e3deb566604db2d5c1576fd9182d1
|
7
|
+
data.tar.gz: 4c6230cd901ace42e406da2474df0a03937138780215bcc82e9dbd942e17d70e93986d329ad923051a1dcbe6cf199835743ad201b2b8191ae5665a473549d933
|
data/config/endpoint.yml
CHANGED
data/lib/sentimeta/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sentimeta::Client::Auth, :vcr do
|
4
|
+
|
5
|
+
it { is_expected.to respond_to(:user) }
|
6
|
+
it { is_expected.to respond_to(:signup) }
|
7
|
+
it { is_expected.to respond_to(:signin) }
|
8
|
+
it { is_expected.to respond_to(:reset_password_token) }
|
9
|
+
it { is_expected.to respond_to(:reset_password) }
|
10
|
+
it { is_expected.to respond_to(:oauth) }
|
11
|
+
it { is_expected.to respond_to(:signout) }
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sentimeta::Client::Data, :vcr do
|
4
|
+
|
5
|
+
it { is_expected.to respond_to(:attributes) }
|
6
|
+
it { is_expected.to respond_to(:medal) }
|
7
|
+
it { is_expected.to respond_to(:search) }
|
8
|
+
|
9
|
+
it 'responds to other data-methods' do
|
10
|
+
%w(criteria spheres objects catalog).each do |meth|
|
11
|
+
is_expected.to respond_to(meth.to_sym)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -18,18 +18,6 @@ describe Sentimeta::Client, :vcr do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
# describe :send_request do
|
23
|
-
# it "should be fine for a valid uri" do
|
24
|
-
# expect { subject.send_request valid_url }.not_to raise_error
|
25
|
-
# end
|
26
|
-
|
27
|
-
# it "should raise an error for invalid uri" do
|
28
|
-
# expect { subject.send_request "invalid" }.to raise_error Sentimeta::Error::Unreachable
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
|
32
|
-
|
33
21
|
describe :endpoints do
|
34
22
|
%i(criteria spheres objects catalog).each do |endpoint|
|
35
23
|
it { should respond_to endpoint }
|
@@ -43,10 +31,6 @@ describe Sentimeta::Client, :vcr do
|
|
43
31
|
expect(subject.public_send endpoint).to be_kind_of Array
|
44
32
|
end
|
45
33
|
end
|
46
|
-
|
47
|
-
# it { should respond_to :prices }
|
48
|
-
# it("#prices should call fetch once") { pending }
|
49
|
-
# it("#prices should return an array") { pending }
|
50
34
|
end
|
51
35
|
|
52
36
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sentimeta::RestClient, :vcr do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
module TestModule extend Sentimeta::RestClient; end
|
7
|
+
end
|
8
|
+
|
9
|
+
it { is_expected.to respond_to(:fetch) }
|
10
|
+
|
11
|
+
describe '#generate_uri' do
|
12
|
+
it 'works without options' do
|
13
|
+
expect(
|
14
|
+
subject.generate_uri(:spheres)
|
15
|
+
).to eq 'http://178.63.216.136/api/v1/spheres'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'generate right uri for attributes' do
|
19
|
+
expect(
|
20
|
+
subject.generate_uri(:attributes, filter: 'actors', sphere: 'movies')
|
21
|
+
).to eq 'http://178.63.216.136/api/v1/movies/attributes/actors'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'generate right uri for prices' do
|
25
|
+
expect(
|
26
|
+
subject.generate_uri(:prices, provider: 'booking', sphere: 'hotels')
|
27
|
+
).to eq 'http://178.63.216.136/api/v1/hotels/prices/booking'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'puts id at the end of URI' do
|
31
|
+
expect(
|
32
|
+
subject.generate_uri(:prices, id: 12345, provider: 'booking', sphere: 'hotels')
|
33
|
+
).to eq 'http://178.63.216.136/api/v1/hotels/prices/booking/12345'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#fetch' do
|
38
|
+
it 'sends get request by default' do
|
39
|
+
expect(::RestClient::Request).to receive(:execute)
|
40
|
+
.with(hash_including(method: :get))
|
41
|
+
.and_call_original
|
42
|
+
|
43
|
+
subject.fetch 'spheres'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'sends right request' do
|
47
|
+
expect(::RestClient::Request).to receive(:execute)
|
48
|
+
.with(hash_including(url: 'http://178.63.216.136/api/v1/hotels/catalog'))
|
49
|
+
.and_call_original
|
50
|
+
|
51
|
+
subject.fetch 'catalog', sphere: 'hotels'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'puts tokens to header' do
|
55
|
+
headers = {
|
56
|
+
'X-SERVER-ACCESS-TOKEN' => 'servertoken',
|
57
|
+
'X-TOKEN' => 'usertoken'
|
58
|
+
}
|
59
|
+
Sentimeta.server_token = 'servertoken'
|
60
|
+
expect(::RestClient::Request).to receive(:execute)
|
61
|
+
.with(hash_including(headers: headers))
|
62
|
+
.and_call_original
|
63
|
+
|
64
|
+
subject.fetch 'catalog', sphere: 'hotels', token: 'usertoken'
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'handle empty parameters normally' do
|
68
|
+
expected_params = { param: :test }
|
69
|
+
expect(::RestClient::Request).to receive(:execute)
|
70
|
+
.with(hash_including(payload: expected_params))
|
71
|
+
.and_call_original
|
72
|
+
|
73
|
+
subject.fetch 'catalog', sphere: 'hotels', blabla: nil, param: :test
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it "responds to shortcut methods" do
|
78
|
+
%i(get post put patch delete options).each do |method|
|
79
|
+
expect(::RestClient::Request).to receive(:execute)
|
80
|
+
.with(hash_including(method: method))
|
81
|
+
.and_return(OpenStruct.new(code: 200, body: ''))
|
82
|
+
subject.public_send(method)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentimeta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Shpakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -126,8 +126,15 @@ files:
|
|
126
126
|
- lib/sentimeta/support.rb
|
127
127
|
- lib/sentimeta/version.rb
|
128
128
|
- sentimeta.gemspec
|
129
|
+
- spec/client/auth_spec.rb
|
130
|
+
- spec/client/data_spec.rb
|
131
|
+
- spec/client/info_spec.rb
|
132
|
+
- spec/client/prices_spec.rb
|
133
|
+
- spec/client/subscription_spec.rb
|
134
|
+
- spec/client/user_reviews_spec.rb
|
129
135
|
- spec/client_spec.rb
|
130
136
|
- spec/model_spec.rb
|
137
|
+
- spec/rest_client_spec.rb
|
131
138
|
- spec/spec_helper.rb
|
132
139
|
homepage: http://toprater.com
|
133
140
|
licenses:
|