aylien_text_api 0.7.0 → 0.8.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 -5
- data/.gitignore +3 -0
- data/README.md +12 -10
- data/aylien_text_api.gemspec +3 -3
- data/lib/aylien_text_api/client.rb +30 -93
- data/lib/aylien_text_api/configuration.rb +2 -4
- data/lib/aylien_text_api/version.rb +1 -1
- data/spec/fixtures/aylien_text_api/client/{microformats_with_invalid_client.yml → elsa_with_invalid_client.yml} +10 -8
- data/spec/fixtures/aylien_text_api/client/{related_with_invalid_params.yml → elsa_with_invalid_params.yml} +15 -24
- data/spec/fixtures/aylien_text_api/client/elsa_with_text.yml +98 -0
- data/spec/fixtures/aylien_text_api/client/{related_with_unauthenticated_client.yml → elsa_with_unauthenticated_client.yml} +10 -8
- data/spec/fixtures/aylien_text_api/client/elsa_with_valid_url.yml +47 -0
- data/spec/fixtures/aylien_text_api/client/elsa_with_value_as_text.yml +92 -0
- data/spec/fixtures/aylien_text_api/client/elsa_with_value_as_valid_url.yml +53 -0
- data/spec/lib/aylien_text_api/client_spec.rb +1 -3
- data/spec/lib/aylien_text_api/elsa.rb +81 -0
- metadata +14 -152
- data/spec/fixtures/aylien_text_api/client/microformats_with_invalid_params.yml +0 -62
- data/spec/fixtures/aylien_text_api/client/microformats_with_unauthenticated_client.yml +0 -42
- data/spec/fixtures/aylien_text_api/client/microformats_with_valid_url.yml +0 -84
- data/spec/fixtures/aylien_text_api/client/microformats_with_value_as_valid_url.yml +0 -84
- data/spec/fixtures/aylien_text_api/client/related_with_invalid_client.yml +0 -38
- data/spec/fixtures/aylien_text_api/client/related_with_phrase.yml +0 -112
- data/spec/fixtures/aylien_text_api/client/related_with_value_as_phrase.yml +0 -112
- data/spec/fixtures/aylien_text_api/client/related_with_value_as_valid_url.yml +0 -62
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_invalid_client.yml +0 -38
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_invalid_params.yml +0 -57
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_text.yml +0 -53
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_unauthenticated_client.yml +0 -42
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_valid_url.yml +0 -97
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_value_as_text.yml +0 -57
- data/spec/fixtures/aylien_text_api/client/unsupervised_classify_with_value_as_valid_url.yml +0 -97
- data/spec/lib/aylien_text_api/microformats.rb +0 -66
- data/spec/lib/aylien_text_api/related.rb +0 -80
- data/spec/lib/aylien_text_api/unsupervised_classify.rb +0 -87
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe "Microformats endpoint" do
|
4
|
-
before do
|
5
|
-
@url = "http://codepen.io/anon/pen/ZYaKbz.html"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "shouldn't be nil with valid url" do
|
9
|
-
VCR.use_cassette('microformats_with_valid_url') do
|
10
|
-
result = @client.microformats(url: @url)
|
11
|
-
result.wont_be_nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "shouldn't be nil with value as valid url" do
|
16
|
-
VCR.use_cassette('microformats_with_value_as_valid_url') do
|
17
|
-
result = @client.microformats(@url)
|
18
|
-
result.wont_be_nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be nil with invalid params" do
|
23
|
-
VCR.use_cassette('microformats_with_invalid_params') do
|
24
|
-
result = @client.microformats(wrong_param: @url)
|
25
|
-
result.must_be_nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should be nil with unauthenticated client" do
|
30
|
-
VCR.use_cassette('microformats_with_unauthenticated_client') do
|
31
|
-
result = @unauthenticated_client.microformats(url: @url)
|
32
|
-
result.must_be_nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should raise Forbidden with unauthenticated client" do
|
37
|
-
VCR.use_cassette('microformats_with_unauthenticated_client') do
|
38
|
-
proc {
|
39
|
-
@unauthenticated_client.microformats!(url: @url)
|
40
|
-
}.must_raise AylienTextApi::Error::Forbidden
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should be nil with invalid client" do
|
45
|
-
VCR.use_cassette('microformats_with_invalid_client') do
|
46
|
-
result = @invalid_client.microformats(url: @url)
|
47
|
-
result.must_be_nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should raise Forbidden with invalid client" do
|
52
|
-
VCR.use_cassette('microformats_with_invalid_client') do
|
53
|
-
proc {
|
54
|
-
@invalid_client.microformats!(url: @url)
|
55
|
-
}.must_raise AylienTextApi::Error::Forbidden
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should raise BadRequest with invalid params" do
|
60
|
-
VCR.use_cassette('microformats_with_invalid_params') do
|
61
|
-
proc {
|
62
|
-
@client.microformats!(wrong_param: @url)
|
63
|
-
}.must_raise AylienTextApi::Error::BadRequest
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
describe "Related endpoint" do
|
2
|
-
before do
|
3
|
-
@phrase = "android"
|
4
|
-
@url = "http://www.bbc.com/sport/0/football/25912393"
|
5
|
-
end
|
6
|
-
|
7
|
-
it "shouldn't be nil with phrase" do
|
8
|
-
VCR.use_cassette('related_with_phrase') do
|
9
|
-
result = @client.related(phrase: @phrase)
|
10
|
-
result.wont_be_nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "shouldn't be nil with value as phrase" do
|
15
|
-
VCR.use_cassette('related_with_value_as_phrase') do
|
16
|
-
result = @client.related(@phrase)
|
17
|
-
result.wont_be_nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should be nil with value as valid url" do
|
22
|
-
VCR.use_cassette('related_with_value_as_valid_url') do
|
23
|
-
result = @client.related(@url)
|
24
|
-
result.must_be_nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should be nil with invalid params" do
|
29
|
-
VCR.use_cassette('related_with_invalid_params') do
|
30
|
-
result = @client.related(wrong_param: @phrase)
|
31
|
-
result.must_be_nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should be nil with unauthenticated client" do
|
36
|
-
VCR.use_cassette('related_with_unauthenticated_client') do
|
37
|
-
result = @unauthenticated_client.related(phrase: @phrase)
|
38
|
-
result.must_be_nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should raise Forbidden with unauthenticated client" do
|
43
|
-
VCR.use_cassette('related_with_unauthenticated_client') do
|
44
|
-
proc {
|
45
|
-
@unauthenticated_client.related!(phrase: @phrase)
|
46
|
-
}.must_raise AylienTextApi::Error::Forbidden
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should be nil with invalid client" do
|
51
|
-
VCR.use_cassette('related_with_invalid_client') do
|
52
|
-
result = @invalid_client.related(phrase: @phrase)
|
53
|
-
result.must_be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should raise Forbidden with invalid client" do
|
58
|
-
VCR.use_cassette('related_with_invalid_client') do
|
59
|
-
proc {
|
60
|
-
@invalid_client.related!(phrase: @phrase)
|
61
|
-
}.must_raise AylienTextApi::Error::Forbidden
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should raise BadRequest with value as valid url" do
|
66
|
-
VCR.use_cassette('related_with_value_as_valid_url') do
|
67
|
-
proc {
|
68
|
-
@client.related!(@url)
|
69
|
-
}.must_raise AylienTextApi::Error::BadRequest
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should raise BadRequest with invalid params" do
|
74
|
-
VCR.use_cassette('related_with_invalid_params') do
|
75
|
-
proc {
|
76
|
-
@client.related!(wrong_param: @text)
|
77
|
-
}.must_raise AylienTextApi::Error::BadRequest
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe "Unsupervised Classify endpoint" do
|
4
|
-
before do
|
5
|
-
@url = "http://techcrunch.com/2014/10/20/the-super-slim-kindle-voyage-is-a-great-travel-companion/"
|
6
|
-
@text = %q(CCTV footage shows the moment a suicide car bomber detonates
|
7
|
-
a device in Beirut on Tuesday. The incident took place in an area
|
8
|
-
of support for Hezbollah and left four people dead with many more wounded.
|
9
|
-
A group calling itself the al-Nusra Front in Lebanon has claimed
|
10
|
-
responsibility for the attack saying it was in retaliation for
|
11
|
-
Hezbollah's military support of president Bashar al-Assad's forces in Syria)
|
12
|
-
@classes = ['voyage', 'travel', 'president']
|
13
|
-
end
|
14
|
-
|
15
|
-
it "shouldn't be nil with valid url" do
|
16
|
-
VCR.use_cassette('unsupervised_classify_with_valid_url') do
|
17
|
-
result = @client.unsupervised_classify(url: @url, classes: @classes)
|
18
|
-
result.wont_be_nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "shouldn't be nil with text" do
|
23
|
-
VCR.use_cassette('unsupervised_classify_with_text') do
|
24
|
-
result = @client.unsupervised_classify(text: @text, classes: @classes)
|
25
|
-
result.wont_be_nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "shouldn't be nil with value as valid url" do
|
30
|
-
VCR.use_cassette('unsupervised_classify_with_value_as_valid_url') do
|
31
|
-
result = @client.unsupervised_classify(@url, classes: @classes)
|
32
|
-
result.wont_be_nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it "shouldn't be nil with value as value" do
|
37
|
-
VCR.use_cassette('unsupervised_classify_with_value_as_text') do
|
38
|
-
result = @client.classify(@text, classes: @classes)
|
39
|
-
result.wont_be_nil
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should be nil with invalid params" do
|
44
|
-
VCR.use_cassette('unsupervised_classify_with_invalid_params') do
|
45
|
-
result = @client.unsupervised_classify(wrong_param: @text, classes: @classes)
|
46
|
-
result.must_be_nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should be nil with unauthenticated client" do
|
51
|
-
VCR.use_cassette('unsupervised_classify_with_unauthenticated_client') do
|
52
|
-
result = @unauthenticated_client.unsupervised_classify(text: @text, classes: @classes)
|
53
|
-
result.must_be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should raise Forbidden with unauthenticated client" do
|
58
|
-
VCR.use_cassette('unsupervised_classify_with_unauthenticated_client') do
|
59
|
-
proc {
|
60
|
-
@unauthenticated_client.unsupervised_classify!(text: @text, classes: @classes)
|
61
|
-
}.must_raise AylienTextApi::Error::Forbidden
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should be nil with invalid client" do
|
66
|
-
VCR.use_cassette('unsupervised_classify_with_invalid_client') do
|
67
|
-
result = @invalid_client.unsupervised_classify(text: @text, classes: @classes)
|
68
|
-
result.must_be_nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should raise Forbidden with invalid client" do
|
73
|
-
VCR.use_cassette('unsupervised_classify_with_invalid_client') do
|
74
|
-
proc {
|
75
|
-
@invalid_client.unsupervised_classify!(text: @text, classes: @classes)
|
76
|
-
}.must_raise AylienTextApi::Error::Forbidden
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should raise BadRequest with invalid params" do
|
81
|
-
VCR.use_cassette('classify_with_invalid_params') do
|
82
|
-
proc {
|
83
|
-
@client.classify!(wrong_param: @text, classes: @classes)
|
84
|
-
}.must_raise AylienTextApi::Error::BadRequest
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|