openamplify 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,98 +0,0 @@
1
- require 'test/unit'
2
- require 'shoulda'
3
- require 'openamplify'
4
-
5
- class OpenAmplifyTest < Test::Unit::TestCase
6
-
7
- context "Client instance" do
8
-
9
- should "raise an error if api key is missing" do
10
- assert_raises ArgumentError do
11
- client = OpenAmplify::Client.new
12
- client.analyze_text("sample")
13
- end
14
- end
15
-
16
- should "not raise an error if api key is present" do
17
- assert_nothing_raised do
18
- client.analyze_text("sample")
19
- end
20
- end
21
-
22
- should "raise an error if api key is not authorized" do
23
- assert_raises OpenAmplify::Forbidden do
24
- client = OpenAmplify::Client.new(:api_key => 'SOME_KEY')
25
- client.analyze_text("sample").reload
26
- end
27
- end
28
-
29
- should "raise an error if api_url is missing" do
30
- assert_raises ArgumentError do
31
- client.api_url = ''
32
- client.analyze_text('sample')
33
- end
34
- end
35
-
36
- should "not raise an error if api_url is present" do
37
- assert_nothing_raised do
38
- client.analyze_text('sample')
39
- end
40
- end
41
-
42
- end # context "Client instance"
43
-
44
- context "Response" do
45
-
46
- should "raise an error if empty text" do
47
- assert_raises OpenAmplify::NotAcceptable do
48
- client.analyze_text('').reload
49
- end
50
- end
51
-
52
- should "not raise an error if there is input text" do
53
- assert_nothing_raised do
54
- client.analyze_text('sample').reload
55
- end
56
- end
57
-
58
- should "raise error if analyis is not supported" do
59
- assert_raises OpenAmplify::NotSupported do
60
- client.analysis = 'not supported'
61
- client.analyze_text('sample').reload
62
- end
63
- end
64
-
65
- #pending "show the request url"
66
-
67
- end # Response
68
-
69
- context "Request methods" do
70
-
71
-
72
- should "raise an error if not supported" do
73
- assert_raises OpenAmplify::NotSupported do
74
- client.method = :delete
75
- client.analyze_text('sample').reload
76
- end
77
- end
78
-
79
- [:get, :post].each do |method|
80
- should "not raise error for #{method}" do
81
- assert_nothing_raised do
82
- client.method = method
83
- client.analyze_text('sample').reload
84
- end
85
- end
86
- end
87
-
88
- end # Request methods
89
-
90
- def client
91
- @client ||= OpenAmplify::Client.new(:api_key => api_key)
92
- end
93
-
94
- def api_key
95
- ENV['OPEN_AMPLIFY_KEY']
96
- end
97
-
98
- end # OpenAmplifyTest