Sha256: 0dab06a9b24b319f76fbc0691546a5af8307ac69b370337615c16bd9e567047f
Contents?: true
Size: 1010 Bytes
Versions: 6
Compression:
Stored size: 1010 Bytes
Contents
module USaidWat module Service class MockComment attr_reader :subreddit, :body, :id, :link_id, :created_utc, :link_title def initialize(dict) data = dict['data'] @subreddit = data['subreddit'] @body = data['body'] @id = data['id'] @link_id = data['link_id'] @created_utc = data['created_utc'] @link_title = data['link_title'] end end class MockUser def initialize(username) @username = username end def comments(n) path = File.join(File.dirname(__FILE__), "..", "..", "features", "fixtures", "#{@username}.json") 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) MockUser.new(username) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems