assistly 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  module Assistly
2
2
  # The version of the gem
3
- VERSION = '0.1.5'.freeze unless defined?(::Assistly::VERSION)
3
+ VERSION = '0.2.0'.freeze unless defined?(::Assistly::VERSION)
4
4
  end
@@ -0,0 +1,134 @@
1
+ require 'helper'
2
+
3
+ describe Assistly::Client do
4
+ Assistly::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Assistly::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
8
+ end
9
+
10
+ describe ".articles" do
11
+
12
+ context "lookup" do
13
+
14
+ before do
15
+ stub_get("topics/1/articles.#{format}").
16
+ to_return(:body => fixture("articles.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
17
+ end
18
+
19
+ it "should post to the correct resource" do
20
+ @client.articles(1)
21
+ a_get("topics/1/articles.#{format}").
22
+ should have_been_made
23
+ end
24
+
25
+ it "should return the articles" do
26
+ articles = @client.articles(1)
27
+
28
+ articles.should be_a Array
29
+ articles.first.article.id.should == 13
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ describe ".article" do
36
+
37
+ context "lookup" do
38
+
39
+ before do
40
+ stub_get("articles/13.#{format}").
41
+ to_return(:body => fixture("article.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
42
+ end
43
+
44
+ it "should get the correct resource" do
45
+ @client.article(13)
46
+ a_get("articles/13.#{format}").
47
+ should have_been_made
48
+ end
49
+
50
+ it "should return up to 100 cases worth of extended information" do
51
+ article = @client.article(13)
52
+
53
+ article.id.should == 13
54
+ article.subject.should == "API Tips"
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ describe ".create_article" do
61
+
62
+ context "create" do
63
+
64
+ before do
65
+ stub_post("topics/1/articles.#{format}").
66
+ to_return(:body => fixture("article_create.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
67
+ end
68
+
69
+ it "should post to the correct resource" do
70
+ @client.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
71
+ a_post("topics/1/articles.#{format}").
72
+ should have_been_made
73
+ end
74
+
75
+ it "should return the articles" do
76
+ article = @client.create_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
77
+
78
+ article.id.should == 13
79
+ end
80
+
81
+ end
82
+ end
83
+
84
+ describe ".update_article" do
85
+
86
+ context "update" do
87
+
88
+ before do
89
+ stub_put("articles/1.#{format}").
90
+ to_return(:body => fixture("article_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
91
+ end
92
+
93
+ it "should post to the correct resource" do
94
+ @client.update_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
95
+ a_put("articles/1.#{format}").
96
+ should have_been_made
97
+ end
98
+
99
+ it "should return the new topic" do
100
+ topic = @client.update_article(1, :subject => "API Tips", :main_content => "Tips on using our API")
101
+
102
+ topic.subject.should == "API Tips"
103
+ topic.main_content.should == "Tips on using our API"
104
+ end
105
+
106
+ end
107
+ end
108
+
109
+ describe ".delete_article" do
110
+
111
+ context "delete" do
112
+
113
+ before do
114
+ stub_delete("articles/1.#{format}").
115
+ to_return(:body => fixture("article_destroy.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
116
+ end
117
+
118
+ it "should post to the correct resource" do
119
+ @client.delete_article(1)
120
+ a_delete("articles/1.#{format}").
121
+ should have_been_made
122
+ end
123
+
124
+ it "should return a successful response" do
125
+ topic = @client.delete_article(1)
126
+ topic.success.should == true
127
+ end
128
+
129
+ end
130
+ end
131
+
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,204 @@
1
+ require 'helper'
2
+
3
+ describe Assistly::Client do
4
+ Assistly::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Assistly::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
8
+ end
9
+
10
+ describe ".macros" do
11
+
12
+ context "lookup" do
13
+
14
+ before do
15
+ stub_get("macros.#{format}").
16
+ to_return(:body => fixture("macros.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
17
+ end
18
+
19
+ it "should get the correct resource" do
20
+ @client.macros
21
+ a_get("macros.#{format}").
22
+ should have_been_made
23
+ end
24
+
25
+ it "should return up to 100 macros worth of extended information" do
26
+ macros = @client.macros
27
+
28
+ macros.should be_a Array
29
+ macros.first.macro.id.should == 11
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ describe ".macro" do
36
+
37
+ context "lookup" do
38
+
39
+ before do
40
+ stub_get("macros/13.#{format}").
41
+ to_return(:body => fixture("macro.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
42
+ end
43
+
44
+ it "should get the correct resource" do
45
+ @client.macro(13)
46
+ a_get("macros/13.#{format}").
47
+ should have_been_made
48
+ end
49
+
50
+ it "should return up to 100 cases worth of extended information" do
51
+ macro = @client.macro(13)
52
+
53
+ macro.id.should == 13
54
+ macro.name.should == "API Macro"
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ describe ".create_macro" do
61
+
62
+ context "create" do
63
+
64
+ before do
65
+ stub_post("macros.#{format}").
66
+ to_return(:body => fixture("macro_create.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
67
+ end
68
+
69
+ it "should post to the correct resource" do
70
+ @client.create_macro("API Macro", :description => "Everything belongs here")
71
+ a_post("macros.#{format}").
72
+ should have_been_made
73
+ end
74
+
75
+ it "should return the new macro" do
76
+ macro = @client.create_macro("API Macro", :description => "Everything belongs here")
77
+
78
+ macro.id.should == 12
79
+ macro.name.should == "API Macro"
80
+ end
81
+
82
+ end
83
+ end
84
+
85
+ describe ".update_macro" do
86
+
87
+ context "update" do
88
+
89
+ before do
90
+ stub_put("macros/13.#{format}").
91
+ to_return(:body => fixture("macro_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
92
+ end
93
+
94
+ it "should post to the correct resource" do
95
+ @client.update_macro(13, :name => "Updated")
96
+ a_put("macros/13.#{format}").
97
+ should have_been_made
98
+ end
99
+
100
+ it "should return the new macro" do
101
+ macro = @client.update_macro(13, :name => "Updated")
102
+
103
+ macro.name.should == "Updated"
104
+ end
105
+
106
+ end
107
+ end
108
+
109
+ describe ".delete_macro" do
110
+
111
+ context "delete" do
112
+
113
+ before do
114
+ stub_delete("macros/1.#{format}").
115
+ to_return(:body => fixture("macro_destroy.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
116
+ end
117
+
118
+ it "should post to the correct resource" do
119
+ @client.delete_macro(1)
120
+ a_delete("macros/1.#{format}").
121
+ should have_been_made
122
+ end
123
+
124
+ it "should return a successful response" do
125
+ macro = @client.delete_macro(1)
126
+ macro.success.should == true
127
+ end
128
+
129
+ end
130
+ end
131
+
132
+ describe ".macro_actions" do
133
+
134
+ context "lookup" do
135
+
136
+ before do
137
+ stub_get("macros/1/actions.#{format}").
138
+ to_return(:body => fixture("macro_actions.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
139
+ end
140
+
141
+ it "should get the correct resource" do
142
+ @client.macro_actions(1)
143
+ a_get("macros/1/actions.#{format}").
144
+ should have_been_made
145
+ end
146
+
147
+ it "should return up to 100 macro actions worth of extended information" do
148
+ macro_actions = @client.macro_actions(1)
149
+
150
+ macro_actions.should be_a Array
151
+ macro_actions.first.action.slug.should == "set-case-description"
152
+ end
153
+
154
+ end
155
+ end
156
+
157
+ describe ".macro_action" do
158
+
159
+ context "lookup" do
160
+
161
+ before do
162
+ stub_get("macros/1/actions/set-case-description.#{format}").
163
+ to_return(:body => fixture("macro_action.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
164
+ end
165
+
166
+ it "should get the correct resource" do
167
+ @client.macro_action(1,"set-case-description")
168
+ a_get("macros/1/actions/set-case-description.#{format}").
169
+ should have_been_made
170
+ end
171
+
172
+ it "should return up to 100 macro actions worth of extended information" do
173
+ macro_action = @client.macro_action(1,"set-case-description")
174
+ macro_action.slug.should == "set-case-description"
175
+ end
176
+
177
+ end
178
+ end
179
+
180
+ describe ".update_macro_action" do
181
+
182
+ context "update" do
183
+
184
+ before do
185
+ stub_put("macros/1/actions/set-case-description.#{format}").
186
+ to_return(:body => fixture("macro_action_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
187
+ end
188
+
189
+ it "should post to the correct resource" do
190
+ @client.update_macro_action(1, "set-case-description", :value => "This is my case description")
191
+ a_put("macros/1/actions/set-case-description.#{format}").
192
+ should have_been_made
193
+ end
194
+
195
+ it "should return the new macro" do
196
+ macro_action = @client.update_macro_action(1, "set-case-description", :value => "This is my case description")
197
+ macro_action.value.should == "Description to be applied"
198
+ end
199
+
200
+ end
201
+ end
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,135 @@
1
+ require 'helper'
2
+
3
+ describe Assistly::Client do
4
+ Assistly::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Assistly::Client.new(:subdomain => "example", :format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS')
8
+ end
9
+
10
+ describe ".topics" do
11
+
12
+ context "lookup" do
13
+
14
+ before do
15
+ stub_get("topics.#{format}").
16
+ to_return(:body => fixture("topics.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
17
+ end
18
+
19
+ it "should get the correct resource" do
20
+ @client.topics
21
+ a_get("topics.#{format}").
22
+ should have_been_made
23
+ end
24
+
25
+ it "should return up to 100 topics worth of extended information" do
26
+ topics = @client.topics
27
+
28
+ topics.should be_a Array
29
+ topics.first.topic.id.should == 1
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ describe ".topic" do
36
+
37
+ context "lookup" do
38
+
39
+ before do
40
+ stub_get("topics/1.#{format}").
41
+ to_return(:body => fixture("topic.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
42
+ end
43
+
44
+ it "should get the correct resource" do
45
+ @client.topic(1)
46
+ a_get("topics/1.#{format}").
47
+ should have_been_made
48
+ end
49
+
50
+ it "should return up to 100 cases worth of extended information" do
51
+ topic = @client.topic(1)
52
+
53
+ topic.id.should == 1
54
+ topic.name.should == "General"
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ describe ".create_topic" do
61
+
62
+ context "create" do
63
+
64
+ before do
65
+ stub_post("topics.#{format}").
66
+ to_return(:body => fixture("topic_create.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
67
+ end
68
+
69
+ it "should post to the correct resource" do
70
+ @client.create_topic("General", :description => "Everything belongs here")
71
+ a_post("topics.#{format}").
72
+ should have_been_made
73
+ end
74
+
75
+ it "should return the new topic" do
76
+ topic = @client.create_topic("General", :description => "Everything belongs here")
77
+
78
+ topic.id.should == 9
79
+ topic.name.should == "General"
80
+ topic.description.should == "Everything belongs here"
81
+ end
82
+
83
+ end
84
+ end
85
+
86
+ describe ".update_topic" do
87
+
88
+ context "update" do
89
+
90
+ before do
91
+ stub_put("topics/1.#{format}").
92
+ to_return(:body => fixture("topic_update.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
93
+ end
94
+
95
+ it "should post to the correct resource" do
96
+ @client.update_topic(1, :name => "Updated", :description => "Updated Description")
97
+ a_put("topics/1.#{format}").
98
+ should have_been_made
99
+ end
100
+
101
+ it "should return the new topic" do
102
+ topic = @client.update_topic(1, :name => "Updated", :description => "Updated Description")
103
+
104
+ topic.name.should == "Updated"
105
+ topic.description.should == "Updated Description"
106
+ end
107
+
108
+ end
109
+ end
110
+
111
+ describe ".delete_topic" do
112
+
113
+ context "delete" do
114
+
115
+ before do
116
+ stub_delete("topics/1.#{format}").
117
+ to_return(:body => fixture("topic_destroy.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
118
+ end
119
+
120
+ it "should post to the correct resource" do
121
+ @client.delete_topic(1)
122
+ a_delete("topics/1.#{format}").
123
+ should have_been_made
124
+ end
125
+
126
+ it "should return a successful response" do
127
+ topic = @client.delete_topic(1)
128
+ topic.success.should == true
129
+ end
130
+
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end