ruby-stackoverflow 0.0.2
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.
- data/.gitignore +17 -0
- data/.rake_tasks +4 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/lib/generators/ruby_stackoverflow/ruby_stackoverflow_generator.rb +31 -0
- data/lib/generators/ruby_stackoverflow/templates/ruby_stackoverflow.rb +1 -0
- data/lib/ruby-stackoverflow.rb +29 -0
- data/lib/ruby-stackoverflow/client.rb +68 -0
- data/lib/ruby-stackoverflow/client/.DS_Store +0 -0
- data/lib/ruby-stackoverflow/client/badges_helper.rb +50 -0
- data/lib/ruby-stackoverflow/client/comments_helper.rb +23 -0
- data/lib/ruby-stackoverflow/client/parse_options.rb +25 -0
- data/lib/ruby-stackoverflow/client/question_helper.rb +61 -0
- data/lib/ruby-stackoverflow/client/resource/answer.rb +7 -0
- data/lib/ruby-stackoverflow/client/resource/badge.rb +7 -0
- data/lib/ruby-stackoverflow/client/resource/comment.rb +8 -0
- data/lib/ruby-stackoverflow/client/resource/notification.rb +8 -0
- data/lib/ruby-stackoverflow/client/resource/permission.rb +8 -0
- data/lib/ruby-stackoverflow/client/resource/post.rb +7 -0
- data/lib/ruby-stackoverflow/client/resource/question.rb +66 -0
- data/lib/ruby-stackoverflow/client/resource/reputation.rb +8 -0
- data/lib/ruby-stackoverflow/client/resource/resource.rb +28 -0
- data/lib/ruby-stackoverflow/client/resource/stackoverflow_error.rb +13 -0
- data/lib/ruby-stackoverflow/client/resource/suggested_edit.rb +8 -0
- data/lib/ruby-stackoverflow/client/resource/tag.rb +19 -0
- data/lib/ruby-stackoverflow/client/resource/user.rb +125 -0
- data/lib/ruby-stackoverflow/client/response_data.rb +20 -0
- data/lib/ruby-stackoverflow/client/user_helper.rb +152 -0
- data/lib/ruby-stackoverflow/configuration.rb +10 -0
- data/lib/ruby-stackoverflow/ruby-stackoverflow_generator.rb +29 -0
- data/lib/ruby-stackoverflow/version.rb +4 -0
- data/ruby-stackoverflow.gemspec +28 -0
- data/spec/fixtures/error.json +5 -0
- data/spec/fixtures/questions.json +28 -0
- data/spec/fixtures/questions_answers.json +23 -0
- data/spec/fixtures/questions_comments.json +39 -0
- data/spec/fixtures/questions_timeline.json +200 -0
- data/spec/fixtures/users.json +32 -0
- data/spec/fixtures/vcr_cassettes/badges.yml +67 -0
- data/spec/fixtures/vcr_cassettes/badges_by_ids.yml +56 -0
- data/spec/fixtures/vcr_cassettes/badges_by_name.yml +55 -0
- data/spec/fixtures/vcr_cassettes/badges_by_recipients.yml +73 -0
- data/spec/fixtures/vcr_cassettes/badges_by_recipients_by_ids.yml +70 -0
- data/spec/fixtures/vcr_cassettes/badges_by_tags.yml +58 -0
- data/spec/fixtures/vcr_cassettes/comments.yml +104 -0
- data/spec/fixtures/vcr_cassettes/comments_by_ids.yml +60 -0
- data/spec/fixtures/vcr_cassettes/error.yml +53 -0
- data/spec/fixtures/vcr_cassettes/featured_questions.yml +62 -0
- data/spec/fixtures/vcr_cassettes/linked_questions.yml +53 -0
- data/spec/fixtures/vcr_cassettes/noanswered_questions.yml +62 -0
- data/spec/fixtures/vcr_cassettes/questions.yml +165 -0
- data/spec/fixtures/vcr_cassettes/questions_answers.yml +63 -0
- data/spec/fixtures/vcr_cassettes/questions_by_ids.yml +62 -0
- data/spec/fixtures/vcr_cassettes/questions_comments.yml +60 -0
- data/spec/fixtures/vcr_cassettes/related_questions.yml +94 -0
- data/spec/fixtures/vcr_cassettes/timeline_questions.yml +68 -0
- data/spec/fixtures/vcr_cassettes/unanswered_questions.yml +62 -0
- data/spec/fixtures/vcr_cassettes/user_timeline.yml +73 -0
- data/spec/fixtures/vcr_cassettes/user_top_answers_with_given_tags.yml +64 -0
- data/spec/fixtures/vcr_cassettes/user_top_questions_with_given_tags.yml +66 -0
- data/spec/fixtures/vcr_cassettes/user_top_tags_by_answers.yml +62 -0
- data/spec/fixtures/vcr_cassettes/user_top_tags_by_questions.yml +58 -0
- data/spec/fixtures/vcr_cassettes/user_write_permissions.yml +56 -0
- data/spec/fixtures/vcr_cassettes/users.yml +61 -0
- data/spec/fixtures/vcr_cassettes/users_answers.yml +65 -0
- data/spec/fixtures/vcr_cassettes/users_badges.yml +60 -0
- data/spec/fixtures/vcr_cassettes/users_by_ids.yml +61 -0
- data/spec/fixtures/vcr_cassettes/users_comments.yml +74 -0
- data/spec/fixtures/vcr_cassettes/users_favorites_questions.yml +74 -0
- data/spec/fixtures/vcr_cassettes/users_featured_questions.yml +53 -0
- data/spec/fixtures/vcr_cassettes/users_mentioned_questions.yml +97 -0
- data/spec/fixtures/vcr_cassettes/users_noanswerquestions.yml +60 -0
- data/spec/fixtures/vcr_cassettes/users_notifications.yml +80 -0
- data/spec/fixtures/vcr_cassettes/users_questions.yml +67 -0
- data/spec/fixtures/vcr_cassettes/users_replied_comments.yml +60 -0
- data/spec/fixtures/vcr_cassettes/users_reputation_questions.yml +59 -0
- data/spec/fixtures/vcr_cassettes/users_suggested_edits.yml +72 -0
- data/spec/fixtures/vcr_cassettes/users_tags.yml +60 -0
- data/spec/fixtures/vcr_cassettes/users_unaccepted_questions.yml +65 -0
- data/spec/fixtures/vcr_cassettes/users_unanswered_questions.yml +77 -0
- data/spec/fixtures/vcr_cassettes/users_unread_notifications.yml +53 -0
- data/spec/helper.rb +45 -0
- data/spec/ruby-stackoverflow/badges_spec.rb +63 -0
- data/spec/ruby-stackoverflow/comments_spec.rb +31 -0
- data/spec/ruby-stackoverflow/question_spec.rb +90 -0
- data/spec/ruby-stackoverflow/user_spec.rb +289 -0
- data/spec/spec_helper.rb +16 -0
- metadata +292 -0
data/spec/helper.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
VCR.configure do |c|
|
|
2
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
3
|
+
c.allow_http_connections_when_no_cassette = true
|
|
4
|
+
c.hook_into :webmock # or :fakeweb
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def configure_stackoverflow
|
|
8
|
+
RubyStackoverflow.configure do|config|
|
|
9
|
+
config.client_key = 'pfllsDjWHeLGWoWIT5rRdA(('
|
|
10
|
+
config.access_token = 'L0J88cciBPHiGtIKCul6Gg))'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def stub_get(url, params={})
|
|
15
|
+
stub_request(:get, stackoverflow_url(url, params))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def fixture_path
|
|
19
|
+
File.expand_path("../fixtures", __FILE__)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def fixture(file)
|
|
23
|
+
File.new(fixture_path + '/' + file)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def json_response(file)
|
|
27
|
+
{
|
|
28
|
+
:body => fixture(file),
|
|
29
|
+
:headers => {
|
|
30
|
+
:content_type => 'application/json; charset=utf-8'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def stackoverflow_url(url, params)
|
|
36
|
+
url = basic_stackoverflow_url + url + '?key=dsadsadasd999&site=stackoverflow'
|
|
37
|
+
params.each do|k,v|
|
|
38
|
+
url.concat("&#{k}=#{v}")
|
|
39
|
+
end
|
|
40
|
+
url
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def basic_stackoverflow_url
|
|
44
|
+
'https://api.stackexchange.com/2.1/'
|
|
45
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module RubyStackoverflow
|
|
3
|
+
describe Client::BadgesHelper do
|
|
4
|
+
before(:each) do
|
|
5
|
+
configure_stackoverflow
|
|
6
|
+
@user_basic_url= 'badges/'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'should find badges' do
|
|
10
|
+
VCR.use_cassette('badges') do
|
|
11
|
+
response = RubyStackoverflow.badges({min: 'gold', max: 'bronze', sort: 'rank'})
|
|
12
|
+
response.data.is_a?(Array).should be_true
|
|
13
|
+
expect(response.data.count).to eq(30)
|
|
14
|
+
expect(response.data.first.name).to eq('cryptography')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should find badges by ids' do
|
|
19
|
+
VCR.use_cassette('badges_by_ids') do
|
|
20
|
+
response = RubyStackoverflow.badges_by_ids([263, 264], {min: 'gold', max: 'bronze', sort: 'rank'})
|
|
21
|
+
response.data.is_a?(Array).should be_true
|
|
22
|
+
expect(response.data.count).to eq(2)
|
|
23
|
+
expect(response.data.first.name).to eq('cryptography')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should find badges by name' do
|
|
28
|
+
VCR.use_cassette('badges_by_name') do
|
|
29
|
+
response = RubyStackoverflow.badges_by_name({inname: 'teacher',min: 'gold', max: 'bronze', sort: 'rank'})
|
|
30
|
+
response.data.is_a?(Array).should be_true
|
|
31
|
+
expect(response.data.count).to eq(1)
|
|
32
|
+
expect(response.data.first.name).to eq('Teacher')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should find recently added badges' do
|
|
37
|
+
VCR.use_cassette('badges_by_recipients') do
|
|
38
|
+
response = RubyStackoverflow.badges_between_dates({page: 1, pagesize: 10, fromdate: '2013-08-01', todate: '2013-10-22'})
|
|
39
|
+
response.data.is_a?(Array).should be_true
|
|
40
|
+
expect(response.data.count).to eq(10)
|
|
41
|
+
expect(response.data.first.name).to eq('Nice Answer')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should find recently added badges by ids' do
|
|
46
|
+
VCR.use_cassette('badges_by_recipients_by_ids') do
|
|
47
|
+
response = RubyStackoverflow.badges_between_dates_by_ids([146, 20],{page: 1, pagesize: 10, fromdate: '2013-08-01', todate: '2013-10-22'})
|
|
48
|
+
response.data.is_a?(Array).should be_true
|
|
49
|
+
expect(response.data.count).to eq(10)
|
|
50
|
+
expect(response.data.first.name).to eq('Nice Question')
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should find badges by tags' do
|
|
55
|
+
VCR.use_cassette('badges_by_tags') do
|
|
56
|
+
response = RubyStackoverflow.badges_by_tags({inname: 'ruby-on-rails',min: 'gold', max: 'bronze', sort: 'rank'})
|
|
57
|
+
response.data.is_a?(Array).should be_true
|
|
58
|
+
expect(response.data.count).to eq(7)
|
|
59
|
+
expect(response.data.first.name).to eq('ruby-on-rails')
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module RubyStackoverflow
|
|
3
|
+
describe Client::CommentsHelper do
|
|
4
|
+
before(:each) do
|
|
5
|
+
configure_stackoverflow
|
|
6
|
+
@comments_basic_url= 'users/'
|
|
7
|
+
WebMock.allow_net_connect!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should fetch comments' do
|
|
11
|
+
VCR.use_cassette('comments') do
|
|
12
|
+
response = RubyStackoverflow.comments({min: 1, max: 10, sort: 'votes'})
|
|
13
|
+
response.data.is_a?(Array).should be_true
|
|
14
|
+
expect(response.data.count).to eq(30)
|
|
15
|
+
expect(response.data.first.edited).to eq(false)
|
|
16
|
+
expect(response.data.first.score).to eq(10)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'should fetch comments by ids' do
|
|
21
|
+
VCR.use_cassette('comments_by_ids') do
|
|
22
|
+
response = RubyStackoverflow.comments_by_ids(['129085', '131326'])
|
|
23
|
+
response.data.is_a?(Array).should be_true
|
|
24
|
+
expect(response.data.count).to eq(2)
|
|
25
|
+
expect(response.data.first.edited).to eq(false)
|
|
26
|
+
expect(response.data.first.score).to eq(10)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module RubyStackoverflow
|
|
4
|
+
describe Client::QuestionHelper do
|
|
5
|
+
before(:each) do
|
|
6
|
+
configure_stackoverflow
|
|
7
|
+
@question_basic_url = 'questions/'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should get questions' do
|
|
11
|
+
VCR.use_cassette('questions') do
|
|
12
|
+
response = RubyStackoverflow.questions
|
|
13
|
+
response.data.is_a?(Array).should be_true
|
|
14
|
+
response.data.last.respond_to?(:answer_count).should be_true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should get questions by id' do
|
|
19
|
+
VCR.use_cassette('questions_by_ids') do
|
|
20
|
+
response = RubyStackoverflow.questions_by_ids(['19294359'])
|
|
21
|
+
response.data.is_a?(Array).should be_true
|
|
22
|
+
response.data.last.respond_to?(:answer_count).should be_true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should get answers of questions' do
|
|
27
|
+
VCR.use_cassette('questions_answers') do
|
|
28
|
+
response = RubyStackoverflow.answers_of_questions(['16067043','19401289'])
|
|
29
|
+
response.data.is_a?(Array).should be_true
|
|
30
|
+
expect(response.data.last.answers.count).to eq(1)
|
|
31
|
+
expect(response.data.first.answers.last.answer_id).to eq(19401432)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should get comments of questions' do
|
|
36
|
+
VCR.use_cassette('questions_comments') do
|
|
37
|
+
response = RubyStackoverflow.comments_of_questions(['13804832'])
|
|
38
|
+
data = response.data.last
|
|
39
|
+
response.data.is_a?(Array).should be_true
|
|
40
|
+
data.respond_to?(:comments).should be_true
|
|
41
|
+
expect(data.comments.first.owner[:user_id]).to eq(87189)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should get linked questions' do
|
|
46
|
+
VCR.use_cassette('linked_questions') do
|
|
47
|
+
response = RubyStackoverflow.linked_questions(['13804832'])
|
|
48
|
+
response.data.is_a?(Array).should be_true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'should get related questions' do
|
|
53
|
+
VCR.use_cassette('related_questions') do
|
|
54
|
+
response = RubyStackoverflow.related_questions(['13804832'])
|
|
55
|
+
response.data.is_a?(Array).should be_true
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'should get timeline questions' do
|
|
60
|
+
VCR.use_cassette('timeline_questions') do
|
|
61
|
+
response = RubyStackoverflow.timeline_of_questions(['13804832','16067043'])
|
|
62
|
+
data = response.data.first
|
|
63
|
+
response.data.is_a?(Array).should be_true
|
|
64
|
+
data.posts.first.respond_to?(:timeline_type).should be_true
|
|
65
|
+
expect(data.posts.first.timeline_type).to eq('comment')
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'should get featured questions' do
|
|
70
|
+
VCR.use_cassette('featured_questions') do
|
|
71
|
+
response = RubyStackoverflow.featured_questions({page: 1,pagesize: 1})
|
|
72
|
+
response.data.is_a?(Array).should be_true
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'should get unanswered questions' do
|
|
77
|
+
VCR.use_cassette('unanswered_questions') do
|
|
78
|
+
response = RubyStackoverflow.unanswered_questions({tagged:'rails',pagesize: 1, page: 1})
|
|
79
|
+
response.data.is_a?(Array).should be_true
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should get noanswered questions' do
|
|
84
|
+
VCR.use_cassette('noanswered_questions') do
|
|
85
|
+
response = RubyStackoverflow.noanswered_questions({tagged:'rails', pagesize: 1, page: 1})
|
|
86
|
+
response.data.is_a?(Array).should be_true
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
module RubyStackoverflow
|
|
3
|
+
describe Client::UserHelper do
|
|
4
|
+
before(:each) do
|
|
5
|
+
configure_stackoverflow
|
|
6
|
+
@user_basic_url= 'users/'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'should find users' do
|
|
10
|
+
VCR.use_cassette('users') do
|
|
11
|
+
response = RubyStackoverflow.users({inname: 'raysrashmi', sort: 'reputation'})
|
|
12
|
+
response.data.is_a?(Array).should be_true
|
|
13
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
14
|
+
expect(response.data.first.creation_date).to eq('2012-04-28 18:05:37 UTC')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should get user by id' do
|
|
19
|
+
VCR.use_cassette('users_by_ids') do
|
|
20
|
+
stub_get(@user_basic_url+'1363236').to_return(json_response('users.json'))
|
|
21
|
+
response = RubyStackoverflow.users_by_ids(['1363236'])
|
|
22
|
+
response.data.is_a?(Array).should be_true
|
|
23
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
24
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should get error' do
|
|
29
|
+
VCR.use_cassette('error') do
|
|
30
|
+
response = RubyStackoverflow.users_by_ids(['1363236&&'])
|
|
31
|
+
response.data.should be_nil
|
|
32
|
+
response.error.should_not be_nil
|
|
33
|
+
expect(response.error.error_code).to eq(404)
|
|
34
|
+
expect(response.error.error_message).to eq("no method found with this name")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should get user answers' do
|
|
39
|
+
VCR.use_cassette('users_answers') do
|
|
40
|
+
response = RubyStackoverflow.users_with_answers(['1363236'],{min: '2013-10-01', max: '2013-10-24'})
|
|
41
|
+
response.data.is_a?(Array).should be_true
|
|
42
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
43
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
44
|
+
expect(response.data.first.answers.count).to eq(13)
|
|
45
|
+
expect(response.data.first.answers.last.answer_id).to eq(19449714)
|
|
46
|
+
expect(response.data.first.answers.last.last_activity_date).to eq('2013-10-18 15:57:17 UTC')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should get user badges' do
|
|
51
|
+
VCR.use_cassette('users_badges') do
|
|
52
|
+
response = RubyStackoverflow.users_with_badges(['1363236'],{order: 'asc'})
|
|
53
|
+
response.data.is_a?(Array).should be_true
|
|
54
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
55
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
56
|
+
expect(response.data.first.badges.count).to eq(5)
|
|
57
|
+
expect(response.data.first.badges.first.name).to eq('Teacher')
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'should get user comments' do
|
|
62
|
+
VCR.use_cassette('users_comments') do
|
|
63
|
+
response = RubyStackoverflow.users_with_comments(['1363236'],{sort: 'votes'})
|
|
64
|
+
response.data.is_a?(Array).should be_true
|
|
65
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
66
|
+
expect(response.data.count).to eq(1)
|
|
67
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
68
|
+
expect(response.data.first.comments.count).to eq(17)
|
|
69
|
+
expect(response.data.first.comments.first.score).to eq(1)
|
|
70
|
+
expect(response.data.first.comments.first.comment_id).to eq(28886246)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should get user replied comments' do
|
|
75
|
+
VCR.use_cassette('users_replied_comments') do
|
|
76
|
+
response = RubyStackoverflow.users_with_replied_comments(['707894','1004415'], '1300151')
|
|
77
|
+
response.data.is_a?(Array).should be_true
|
|
78
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
79
|
+
expect(response.data.first.display_name).to eq('felipeclopes')
|
|
80
|
+
expect(response.data.first.comments.count).to eq(1)
|
|
81
|
+
expect(response.data.first.comments.first.score).to eq(0)
|
|
82
|
+
expect(response.data.first.comments.first.comment_id).to eq(28452392)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'should get users favorites questions' do
|
|
87
|
+
VCR.use_cassette('users_favorites_questions') do
|
|
88
|
+
response = RubyStackoverflow.users_with_favorites_questions(['707894','1004415'])
|
|
89
|
+
response.data.is_a?(Array).should be_true
|
|
90
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
91
|
+
expect(response.data.first.display_name).to eq('Joel Grannas')
|
|
92
|
+
expect(response.data.first.questions.count).to eq(1)
|
|
93
|
+
expect(response.data.first.questions.last.view_count).to eq(151)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
it 'should get questions where users are mentioned' do
|
|
97
|
+
VCR.use_cassette('users_mentioned_questions') do
|
|
98
|
+
response = RubyStackoverflow.users_with_mentioned_comments(['707894','1004415'])
|
|
99
|
+
response.data.is_a?(Array).should be_true
|
|
100
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
101
|
+
expect(response.data.first.display_name).to eq('Carlos Drew')
|
|
102
|
+
expect(response.data.first.comments.count).to eq(1)
|
|
103
|
+
expect(response.data.first.comments.last.score).to eq(0)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'should get users notifications' do
|
|
108
|
+
VCR.use_cassette('users_notifications') do
|
|
109
|
+
response = RubyStackoverflow.users_notifications('1363236')
|
|
110
|
+
response.data.is_a?(Array).should be_true
|
|
111
|
+
response.data.last.respond_to?(:notification_type).should be_true
|
|
112
|
+
expect(response.data.first.site[:site_type]).to eq('main_site')
|
|
113
|
+
expect(response.data.count).to eq(16)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
it 'should get users unread notifications' do
|
|
117
|
+
VCR.use_cassette('users_unread_notifications') do
|
|
118
|
+
response = RubyStackoverflow.users_unread_notifications('1363236')
|
|
119
|
+
response.data.is_a?(Array).should be_true
|
|
120
|
+
response.data.last.respond_to?(:notification_type).should be_false
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should get users questions' do
|
|
125
|
+
VCR.use_cassette('users_questions') do
|
|
126
|
+
response = RubyStackoverflow.users_questions(['1363236'])
|
|
127
|
+
response.data.is_a?(Array).should be_true
|
|
128
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
129
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
130
|
+
expect(response.data.first.questions.count).to eq(3)
|
|
131
|
+
expect(response.data.first.questions.last.view_count).to eq(65)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'should get users featured questions' do
|
|
136
|
+
VCR.use_cassette('users_featured_questions') do
|
|
137
|
+
response = RubyStackoverflow.users_featured_questions(['1363236'])
|
|
138
|
+
response.data.is_a?(Array).should be_true
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'should get users no answer questions' do
|
|
143
|
+
VCR.use_cassette('users_noanswerquestions') do
|
|
144
|
+
response = RubyStackoverflow.users_noanswers_questions(['1363236'])
|
|
145
|
+
response.data.is_a?(Array).should be_true
|
|
146
|
+
response.data.should_not be_empty
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it 'should get users unanswered questions' do
|
|
151
|
+
VCR.use_cassette('users_unanswered_questions') do
|
|
152
|
+
response = RubyStackoverflow.users_unanswered_questions(['707894'])
|
|
153
|
+
response.data.is_a?(Array).should be_true
|
|
154
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
155
|
+
expect(response.data.first.display_name).to eq('felipeclopes')
|
|
156
|
+
expect(response.data.first.questions.count).to eq(6)
|
|
157
|
+
expect(response.data.first.questions.last.view_count).to eq(1344)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'should get users unaccepted questions' do
|
|
162
|
+
VCR.use_cassette('users_unaccepted_questions') do
|
|
163
|
+
response = RubyStackoverflow.users_unaccepted_questions(['1363236'])
|
|
164
|
+
response.data.is_a?(Array).should be_true
|
|
165
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
166
|
+
expect(response.data.first.display_name).to eq('raysrashmi')
|
|
167
|
+
expect(response.data.first.questions.count).to eq(2)
|
|
168
|
+
expect(response.data.first.questions.last.view_count).to eq(65)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it 'should get users reputation' do
|
|
173
|
+
VCR.use_cassette('users_reputation_questions') do
|
|
174
|
+
response = RubyStackoverflow.users_reputations(['1363236'])
|
|
175
|
+
response.data.is_a?(Array).should be_true
|
|
176
|
+
expect(response.data.count).to eq(1)
|
|
177
|
+
expect(response.data.first.reputations.count).to eq(12)
|
|
178
|
+
expect(response.data.first.reputations.last.vote_type).to eq('down_votes')
|
|
179
|
+
expect(response.data.first.reputations.last.post_type).to eq('question')
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'should get users suggested edits' do
|
|
184
|
+
VCR.use_cassette('users_suggested_edits') do
|
|
185
|
+
response = RubyStackoverflow.users_suggested_edits(['707894'])
|
|
186
|
+
response.data.is_a?(Array).should be_true
|
|
187
|
+
expect(response.data.count).to eq(1)
|
|
188
|
+
response.data.last.respond_to?(:display_name).should be_true
|
|
189
|
+
expect(response.data.first.display_name).to eq('felipeclopes')
|
|
190
|
+
expect(response.data.first.suggested_edits.count).to eq(8)
|
|
191
|
+
expect(response.data.first.suggested_edits.last.post_type).to eq('answer')
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'should get users tags' do
|
|
196
|
+
VCR.use_cassette('users_tags') do
|
|
197
|
+
response = RubyStackoverflow.users_tags(['707894'],{min: 1, max: 10, sort: 'popular' })
|
|
198
|
+
response.data.is_a?(Array).should be_true
|
|
199
|
+
expect(response.data.count).to eq(1)
|
|
200
|
+
response.data.last.respond_to?(:user_id).should be_true
|
|
201
|
+
expect(response.data.first.tags.count).to eq(30)
|
|
202
|
+
expect(response.data.first.tags.last.name).to eq('angularjs-directive')
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'should get user top answers for specific tags' do
|
|
207
|
+
VCR.use_cassette('user_top_answers_with_given_tags') do
|
|
208
|
+
response = RubyStackoverflow.users_top_answers_with_given_tags('707894',['ruby', 'rails'])
|
|
209
|
+
response.data.is_a?(Array).should be_true
|
|
210
|
+
expect(response.data.count).to eq(1)
|
|
211
|
+
response.data.last.respond_to?(:user_id).should be_true
|
|
212
|
+
expect(response.data.first.answers.count).to eq(9)
|
|
213
|
+
expect(response.data.first.answers.last.score).to eq(0)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it 'should get user top questions for specific tags' do
|
|
218
|
+
VCR.use_cassette('user_top_questions_with_given_tags') do
|
|
219
|
+
response = RubyStackoverflow.users_top_questions_with_given_tags('707894',['ruby', 'rails'])
|
|
220
|
+
response.data.is_a?(Array).should be_true
|
|
221
|
+
expect(response.data.count).to eq(1)
|
|
222
|
+
response.data.last.respond_to?(:user_id).should be_true
|
|
223
|
+
expect(response.data.first.questions.count).to eq(3)
|
|
224
|
+
expect(response.data.first.questions.last.score).to eq(-2)
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it 'should Ggt the top tags (by score) a user has posted answers in' do
|
|
229
|
+
VCR.use_cassette('user_top_tags_by_answers') do
|
|
230
|
+
response = RubyStackoverflow.user_top_tags_by_answers('707894')
|
|
231
|
+
data = response.data
|
|
232
|
+
|
|
233
|
+
data.is_a?(Array).should be_true
|
|
234
|
+
expect(data.count).to eq(1)
|
|
235
|
+
|
|
236
|
+
data.last.respond_to?(:user_id).should be_true
|
|
237
|
+
|
|
238
|
+
expect(data.first.tags.count).to eq(30)
|
|
239
|
+
expect(data.first.tags.last.tag_name).to eq('asp.net-mvc')
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it 'should Ggt the top tags (by score) a user has posted questions' do
|
|
244
|
+
VCR.use_cassette('user_top_tags_by_questions') do
|
|
245
|
+
response = RubyStackoverflow.user_top_tags_by_questions('707894')
|
|
246
|
+
data = response.data
|
|
247
|
+
|
|
248
|
+
data.is_a?(Array).should be_true
|
|
249
|
+
expect(data.count).to eq(1)
|
|
250
|
+
|
|
251
|
+
data.last.respond_to?(:user_id).should be_true
|
|
252
|
+
|
|
253
|
+
expect(data.first.tags.count).to eq(12)
|
|
254
|
+
expect(data.first.tags.last.tag_name).to eq('timezone')
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it 'should get user timeline' do
|
|
259
|
+
VCR.use_cassette('user_timeline') do
|
|
260
|
+
response = RubyStackoverflow.users_timeline(['1363236'],{fromdate: '2013-10-17', todate: '2013-10-20'})
|
|
261
|
+
data = response.data
|
|
262
|
+
|
|
263
|
+
data.is_a?(Array).should be_true
|
|
264
|
+
expect(data.count).to eq(1)
|
|
265
|
+
|
|
266
|
+
data.last.respond_to?(:user_id).should be_true
|
|
267
|
+
|
|
268
|
+
expect(data.first.posts.count).to eq(16)
|
|
269
|
+
expect(data.first.posts.last.timeline_type).to eq('revision')
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it 'should get user write permission' do
|
|
274
|
+
VCR.use_cassette('user_write_permissions') do
|
|
275
|
+
response = RubyStackoverflow.user_write_permissions('1363236')
|
|
276
|
+
data = response.data
|
|
277
|
+
|
|
278
|
+
data.is_a?(Array).should be_true
|
|
279
|
+
expect(data.count).to eq(1)
|
|
280
|
+
|
|
281
|
+
data.last.respond_to?(:user_id).should be_true
|
|
282
|
+
|
|
283
|
+
expect(data.first.permissions.count).to eq(3)
|
|
284
|
+
expect(data.first.permissions.last.can_edit).to eq(true)
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|