Sha256: daad69c045c753719f05b6477a8420c09e624a218959744e0ccdb3c6d2f0a405
Contents?: true
Size: 919 Bytes
Versions: 2
Compression:
Stored size: 919 Bytes
Contents
require 'json' require 'yajl' class FakeResponse def self.render(resource, id = nil, collection = false) new(resource, id, collection).render end def initialize(resource, id = nil, collection = false) @resource, @id, @collection = resource, id, collection end def render collection ? '[' + output + ']' : output end private attr_reader :resource, :id, :collection def output return converted if id raw end def converted JSON(parsed) end def parsed @parsed ||= Yajl::Parser.parse(raw).merge!('id' => id) end def raw @raw ||= File .read(File.dirname(__FILE__) + '/../remotes/' + filename) end def filename testing || reality end def testing resource + '_200.json' if testing? end def testing? id =~ /^200/ end def reality return [resource, '_', id, '.json'].join if id [resource, '.json'].join end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
troo-0.0.11 | test/support/fake_trello/fake_response.rb |
troo-0.0.10 | test/support/fake_trello/fake_response.rb |