pilha 0.1.6 → 0.1.7

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.
Files changed (31) hide show
  1. data/lib/pilha.rb +18 -19
  2. data/lib/pilha/stack_overflow/answer.rb +0 -5
  3. data/lib/pilha/stack_overflow/badge.rb +1 -6
  4. data/lib/pilha/stack_overflow/base.rb +7 -4
  5. data/lib/pilha/stack_overflow/comment.rb +0 -5
  6. data/lib/pilha/stack_overflow/question.rb +20 -5
  7. data/lib/pilha/stack_overflow/statistics.rb +3 -10
  8. data/lib/pilha/stack_overflow/user.rb +0 -7
  9. data/pilha.gemspec +1 -1
  10. data/spec/fixtures/all_tags.json +287 -0
  11. data/spec/fixtures/all_tags.json.gz +0 -0
  12. data/spec/fixtures/favorite_questions_by_user_id.json +496 -0
  13. data/spec/fixtures/favorite_questions_by_user_id.json.gz +0 -0
  14. data/spec/fixtures/post_comments.json +6 -0
  15. data/spec/fixtures/questions_tagged_gwt_and_googleappengine.json +901 -0
  16. data/spec/fixtures/questions_tagged_gwt_and_googleappengine.json.gz +0 -0
  17. data/spec/fixtures/questions_tagged_ruby.json +877 -0
  18. data/spec/fixtures/questions_tagged_ruby.json.gz +0 -0
  19. data/spec/fixtures/questions_unanswered.json +845 -0
  20. data/spec/fixtures/questions_unanswered.json.gz +0 -0
  21. data/spec/fixtures/revisions_by_id.json +25 -0
  22. data/spec/fixtures/search_intitle_ruby.json +872 -0
  23. data/spec/fixtures/search_tagged_ruby_rails.json +877 -0
  24. data/spec/fixtures/tags_by_user_id.json +357 -0
  25. data/spec/fixtures/tags_by_user_id.json.gz +0 -0
  26. data/spec/fixtures/user_tags.json +357 -0
  27. data/spec/pilha/stack_overflow/badge_spec.rb +0 -4
  28. data/spec/pilha/stack_overflow/question_spec.rb +65 -0
  29. data/spec/pilha/stack_overflow/statistics_spec.rb +0 -4
  30. data/spec/spec_helper.rb +6 -0
  31. metadata +20 -3
@@ -2,10 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe StackExchange::StackOverflow::Badge do
4
4
 
5
- before do
6
- StackExchange::StackOverflow::Client.config
7
- end
8
-
9
5
  describe 'when querying for badges' do
10
6
  it 'should return all badges' do
11
7
  response = StackOverflow::Badge.all
@@ -60,4 +60,69 @@ describe StackExchange::StackOverflow::Question do
60
60
  question.title.should == "Getting rid of gcc shift by negative warning"
61
61
  question.owner.id.should == 333
62
62
  end
63
+
64
+ it 'should find questions favorite to a user identified by id' do
65
+ response = StackOverflow::Question.find_favorites_by_user_id 549
66
+ response.total.should == 17
67
+ response.page.should == 1
68
+ response.pagesize.should == 30
69
+
70
+ questions = response.questions
71
+
72
+ question = response.questions.first
73
+
74
+ question.tags.should == ['nhibernate']
75
+ question.answer_count.should == 7
76
+ question.question_timeline_url.should == "/questions/451664/timeline"
77
+ question.question_comments_url.should == "/questions/451664/comments"
78
+ question.question_answers_url.should == "/questions/451664/answers"
79
+ question.id.should == 451664
80
+
81
+ owner = question.owner
82
+ owner.id.should == 52390
83
+ owner.user_type.should == "registered"
84
+ owner.display_name.should == "Przemek"
85
+ owner.reputation.should == 360
86
+ owner.email_hash.should == "46ee3f5f203756778eb8af634bbbfb7e"
87
+
88
+ question.creation_date.should == 1232134747
89
+ question.last_activity_date.should == 1274935956
90
+ question.up_vote_count.should == 2
91
+ question.down_vote_count.should be_zero
92
+ question.view_count.should == 886
93
+ question.score.should == 2
94
+ question.community_owned.should be_false
95
+ question.title.should == "Is there any NHibernate book?"
96
+ end
97
+
98
+
99
+
100
+ it 'should get questions by tag' do
101
+ response = StackOverflow::Question.find_by_tags('ruby')
102
+ response.total.should == 10153
103
+
104
+ questions = response.questions
105
+ questions.each do |question|
106
+ question.tags.should include 'ruby'
107
+ end
108
+ end
109
+
110
+ it 'should get questions containing multiple tags' do
111
+ response = StackOverflow::Question.find_by_tags('gwt', 'google-app-engine')
112
+
113
+ questions = response.questions
114
+ questions.each do |question|
115
+ question.tags.should include 'gwt'
116
+ question.tags.should include 'google-app-engine'
117
+ end
118
+ end
119
+
120
+ it 'should get unanswered questions' do
121
+ response = StackOverflow::Question.unanswered
122
+ response.total.should == 110617
123
+ response.questions.size.should == response.pagesize
124
+
125
+ response.questions.first.id.should == 2965530
126
+ response.questions.first.tags.should == ['javascript', 'twitter', 'twitterapi']
127
+ end
63
128
  end
@@ -2,10 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe StackExchange::StackOverflow::Statistics do
4
4
 
5
- before do
6
- StackExchange::StackOverflow::Client.config
7
- end
8
-
9
5
  describe 'when querying for statistics' do
10
6
  it "should return the stack overflow's statistics" do
11
7
  response = StackOverflow::Statistics.all
data/spec/spec_helper.rb CHANGED
@@ -46,3 +46,9 @@ register(:url => 'users/555/', :body => 'users_by_id')
46
46
  register(:url => 'users/549/comments/', :body => 'comments_by_user_id')
47
47
  register(:url => 'users/549/mentioned/', :body => 'comments_by_mentioned_user_id')
48
48
  register(:url => 'users/77814/comments/549/', :body => 'comments_by_user_to_mentioned_user')
49
+ register(:url => 'users/549/favorites/', :body => 'favorite_questions_by_user_id')
50
+ register(:url => 'questions/?tagged=ruby', :body => 'questions_tagged_ruby')
51
+ register(:url => 'questions/?tagged=gwt+google-app-engine', :body => 'questions_tagged_gwt_and_googleappengine')
52
+ register(:url => 'questions/unanswered/', :body => 'questions_unanswered')
53
+ register(:url => 'tags/', :body => 'all_tags')
54
+ register(:url => 'users/549/tags/', :body => 'tags_by_user_id')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dalto Curvelano Junior
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-31 00:00:00 -03:00
17
+ date: 2010-06-03 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -50,19 +50,30 @@ files:
50
50
  - spec/fixtures/question_by_user_id.json.gz
51
51
  - spec/fixtures/users_by_id.json
52
52
  - spec/fixtures/badges.json
53
+ - spec/fixtures/questions_unanswered.json
54
+ - spec/fixtures/questions_tagged_ruby.json.gz
53
55
  - spec/fixtures/comments_by_user_to_mentioned_user.json
54
56
  - spec/fixtures/answer_with_comments.json
55
57
  - spec/fixtures/answers_by_id.json.gz
58
+ - spec/fixtures/search_tagged_ruby_rails.json
56
59
  - spec/fixtures/stats.json
57
60
  - spec/fixtures/answer_with_comments.json.gz
61
+ - spec/fixtures/user_tags.json
58
62
  - spec/fixtures/badges_name.json
59
63
  - spec/fixtures/answers_by_question_id.json.gz
60
64
  - spec/fixtures/badges_tag_based.json
61
65
  - spec/fixtures/badges.json.gz
62
66
  - spec/fixtures/comments.json
63
67
  - spec/fixtures/question_by_id.json
68
+ - spec/fixtures/tags_by_user_id.json.gz
69
+ - spec/fixtures/search_intitle_ruby.json
64
70
  - spec/fixtures/question_by_id_with_body.json.gz
71
+ - spec/fixtures/favorite_questions_by_user_id.json.gz
72
+ - spec/fixtures/questions_unanswered.json.gz
65
73
  - spec/fixtures/question_by_id.json.gz
74
+ - spec/fixtures/revisions_by_id.json
75
+ - spec/fixtures/all_tags.json.gz
76
+ - spec/fixtures/questions_tagged_ruby.json
66
77
  - spec/fixtures/comments_by_user_to_mentioned_user_id.json.gz
67
78
  - spec/fixtures/answer_comments.json
68
79
  - spec/fixtures/questions.json
@@ -74,18 +85,24 @@ files:
74
85
  - spec/fixtures/users.json
75
86
  - spec/fixtures/comments_by_mentioned_user_id.json.gz
76
87
  - spec/fixtures/comments_by_user_id.json.gz
88
+ - spec/fixtures/questions_tagged_gwt_and_googleappengine.json
77
89
  - spec/fixtures/users_answers.json
78
90
  - spec/fixtures/questions_by_user_id.json.gz
79
91
  - spec/fixtures/users_answers.json.gz
80
92
  - spec/fixtures/badges_by_id.json
81
93
  - spec/fixtures/comments_by_question_id.json
82
94
  - spec/fixtures/badges_by_id.json.gz
95
+ - spec/fixtures/favorite_questions_by_user_id.json
83
96
  - spec/fixtures/badges_tag_based.json.gz
97
+ - spec/fixtures/tags_by_user_id.json
84
98
  - spec/fixtures/comments_by_user_id.json
99
+ - spec/fixtures/questions_tagged_gwt_and_googleappengine.json.gz
85
100
  - spec/fixtures/questions.json.gz
86
101
  - spec/fixtures/questions_by_user_id.json
87
102
  - spec/fixtures/question_by_id_with_body.json
88
103
  - spec/fixtures/answers_by_question_id.json
104
+ - spec/fixtures/post_comments.json
105
+ - spec/fixtures/all_tags.json
89
106
  - spec/fixtures/questions.part
90
107
  - spec/fixtures/comments_by_mentioned_user_id.json
91
108
  - spec/fixtures/badges_by_id_page2.json.gz