lib/usaidwat/service.rb in usaidwat-0.1.4 vs lib/usaidwat/service.rb in usaidwat-0.1.5
- old
+ new
@@ -17,12 +17,16 @@
@username = username
end
def comments(n)
path = File.join(File.dirname(__FILE__), "..", "..", "features", "fixtures", "#{@username}.json")
- json = IO.read(path)
- json = JSON.parse(json)
- json['data']['children'].map { |d| MockComment.new(d) }
+ if File.exists?(path)
+ json = IO.read(path)
+ json = JSON.parse(json)
+ json['data']['children'].map { |d| MockComment.new(d) }
+ else
+ raise USaidWat::Client::NoSuchUserError, @username
+ end
end
end
class MockService
def user(username)