teachstreet 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/teachstreet.rb CHANGED
@@ -90,6 +90,13 @@ module Teachstreet
90
90
  has_one :location
91
91
  end
92
92
 
93
+ class Question < Result
94
+ has_many :answers
95
+ end
96
+
97
+ class Answer < Result
98
+ end
99
+
93
100
  class Client
94
101
  include HTTParty
95
102
 
@@ -146,6 +153,13 @@ module Teachstreet
146
153
  end
147
154
  end
148
155
 
156
+ # find questions
157
+ def questions(options={})
158
+ process(self.class.get("/questions.json", :query => options)).map do |r|
159
+ Question.new(r)
160
+ end
161
+ end
162
+
149
163
  private
150
164
 
151
165
  def process(result)
@@ -1,3 +1,3 @@
1
1
  module Teachstreet
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -180,4 +180,38 @@ describe Teachstreet do
180
180
  teacher_request.subcategory_id.should eql(172)
181
181
  end
182
182
 
183
+ it "question list all", :focus => true do
184
+ result = @client.questions
185
+ result.should_not be_empty
186
+ question = result.first
187
+ question.id.should_not be_nil
188
+ question.url.should_not be_nil
189
+ question.anonymous.should_not be_nil
190
+ question.title.should_not be_nil
191
+ question.body.should_not be_nil
192
+ question.subcategory_id.should_not be_nil
193
+ question.subcategory_name.should_not be_nil
194
+ question.category_id.should_not be_nil
195
+ question.category_name.should_not be_nil
196
+ question.asked_at.should_not be_nil
197
+ question.author_name.should_not be_nil
198
+ question.answers_count.should_not be_nil
199
+ end
200
+
201
+ it "questions with answers", :focus => true do
202
+ result = @client.questions(:with_answers => true)
203
+ result.should_not be_empty
204
+ question = result.first
205
+ question.answers_count.should_not be_zero
206
+ question.answers.should_not be_empty
207
+ answer = question.answers.first
208
+ answer.should_not be_nil
209
+ answer.id.should_not be_nil
210
+ answer.author_name.should_not be_nil
211
+ answer.body.should_not be_nil
212
+ answer.helpful.should_not be_nil
213
+ answer.anonymous.should_not be_nil
214
+ answer.answered_at.should_not be_nil
215
+ end
216
+
183
217
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teachstreet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Scott Windsor
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-14 00:00:00 -07:00
18
+ date: 2011-06-21 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency